MXS-1502: Prune session commands

The session command history is now compacted to contain only the first and
last execution of a session command. This should still allow most of the
more eccentric use-cases of user variables while keeping the session
command history smaller.

Added some convenience functions into the SessionCommand class to make the
pruning process easier.
This commit is contained in:
Markus Mäkelä
2018-03-28 15:20:28 +03:00
parent ce853d3f7f
commit e57ac4b0a3
4 changed files with 97 additions and 5 deletions

View File

@ -23,6 +23,10 @@
namespace maxscale
{
class SessionCommand;
typedef std::tr1::shared_ptr<SessionCommand> SSessionCommand;
typedef std::list<SSessionCommand> SessionCommandList;
class SessionCommand
{
SessionCommand(const SessionCommand&);
@ -78,6 +82,29 @@ public:
*/
std::string to_string();
/**
* @brief Equality comparison
*
* @return True if @c rhs is equal
*/
bool eq(const SessionCommand& rhs) const;
class Equals: public std::unary_function<const SSessionCommand&, bool>
{
public:
Equals(const SSessionCommand& base):
m_base(base)
{}
bool operator ()(const SSessionCommand& rhs)
{
return m_base->eq(*rhs);
}
private:
const SSessionCommand& m_base;
};
private:
mxs::Buffer m_buffer; /**< The buffer containing the command */
uint8_t m_command; /**< The command being executed */
@ -85,7 +112,14 @@ private:
bool m_reply_sent; /**< Whether the session command reply has been sent */
};
typedef std::tr1::shared_ptr<SessionCommand> SSessionCommand;
typedef std::list<SSessionCommand> SessionCommandList;
inline bool operator ==(const SessionCommand& lhs, const SessionCommand& rhs)
{
return lhs.eq(rhs);
}
inline bool operator !=(const SessionCommand& lhs, const SessionCommand& rhs)
{
return !lhs.eq(rhs);
}
}