Clean up readconnroute

Moved method documentation into the headers and removed the local
variables storing pointers to this.
This commit is contained in:
Markus Mäkelä
2019-01-08 12:55:41 +02:00
parent d6df5a7d6a
commit 5613f31bc7
2 changed files with 140 additions and 114 deletions

View File

@ -19,8 +19,6 @@
#define MXS_MODULE_NAME "readconnroute"
#include <maxscale/ccdefs.hh>
#include <maxscale/dcb.hh>
#include <maxscale/service.hh>
#include <maxscale/router.hh>
class ReadConn;
@ -35,21 +33,50 @@ public:
uint32_t bitmask, uint32_t bitvalue);
~ReadConnSession();
int routeQuery(GWBUF*);
/**
* Route data from client to the backend.
*
* @param queue Buffer containing the data to route
*
* @return Returns 1 on success and 0 on error
*/
int routeQuery(GWBUF* queue);
/**
* Closes the router session
*/
void close();
/**
* Route reply from backend to the client
*
* @param pPacket Buffer containing the backend's response
* @param pBackend The backend that responded to the query
*/
void clientReply(GWBUF* pPacket, DCB* pBackend);
/**
* Handle connection errors
*
* @param pMessage Buffer containing the error message
* @param pProblem The DCB that is the source of the problem
* @param action The action to take
* @param pSuccess Pointer where the result of the error handling is stored
*/
void handleError(GWBUF* pMessage,
DCB* pProblem,
mxs_error_action_t action,
bool* pSuccess);
ReadConn* instance;
SERVER_REF* backend; /*< Backend used by the client session */
DCB* backend_dcb;/*< DCB Connection to the backend */
DCB* client_dcb; /**< Client DCB */
uint32_t bitmask; /*< Bitmask to apply to server->status */
uint32_t bitvalue; /*< Session specific required value of server->status */
private:
ReadConn* m_instance; /**< Router instance */
SERVER_REF* m_backend; /**< Backend used by the client session */
DCB* m_dcb; /**< DCB Connection to the backend */
DCB* m_client_dcb; /**< Client DCB */
uint32_t m_bitmask; /**< Bitmask to apply to server->status */
uint32_t m_bitvalue; /**< Session specific required value of server->status */
bool connection_is_valid() const;
};
/**
@ -57,8 +84,8 @@ public:
*/
struct Stats
{
int n_sessions = 0; /*< Number sessions created */
int n_queries = 0; /*< Number of queries forwarded */
int n_sessions = 0; /**< Number sessions created */
int n_queries = 0; /**< Number of queries forwarded */
};
/**
@ -67,18 +94,75 @@ struct Stats
class ReadConn : public mxs::Router<ReadConn, ReadConnSession>
{
public:
/**
* Create a new RadConn instance
*
* @param service The service this router is being create for
* @param params List of parameters for this service
*
* @return The new instance or nullptr on error
*/
static ReadConn* create(SERVICE* service, MXS_CONFIG_PARAMETER* params);
/**
* Create a new session for this router instance
*
* @param session The session object
*
* @return Router session or nullptr on error
*/
ReadConnSession* newSession(MXS_SESSION* pSession);
void diagnostics(DCB* pDcb);
json_t* diagnostics_json() const;
uint64_t getCapabilities();
bool configure(MXS_CONFIG_PARAMETER* params);
bool connection_is_valid(ReadConnSession* router_cli_ses);
uint64_t bitmask_and_bitvalue = 0; /*< Lower 32-bits for bitmask and upper for bitvalue */
Stats stats; /*< Statistics for this router */
/**
* Display router diagnostics
*
* @param dcb DCB to send diagnostics to
*/
void diagnostics(DCB* pDcb);
/**
* Get router diagnostics in JSON
*
* @return JSON data representing the router instance
*/
json_t* diagnostics_json() const;
/**
* Get router capability bits
*
* @return The router capability bits
*/
uint64_t getCapabilities();
/**
* Reconfigure the router instance
*
* @param params New configuration parameters
*
* @return True if router reconfiguration was successful
*/
bool configure(MXS_CONFIG_PARAMETER* params);
/**
* Get the root master server for the service
*
* @return The root master or nullptr if no master is found
*/
SERVER_REF* get_root_master();
/**
* Get statistics
*
* @return Reference to statistics object
*/
Stats& stats()
{
return m_stats;
}
private:
ReadConn(SERVICE* service);
uint64_t m_bitmask_and_bitvalue = 0; /**< Lower 32-bits for bitmask and upper for bitvalue */
Stats m_stats; /**< Statistics for this router */
};