Refactor readwritesplit connection creation

The connections for a router session can now be done without a constructed
router session. This simplifies the creation of new router session by
removing the need to handle memory allocations.

Readwritesplit router sessions are now created in the static `create`
function which handles the actual creation of the connections and
allocation of the session itself.
This commit is contained in:
Markus Mäkelä
2017-08-17 08:18:16 +03:00
parent 46b7db1d45
commit ca4dbf5d0d
4 changed files with 108 additions and 87 deletions

View File

@ -73,7 +73,16 @@ class RWSplitSession
RWSplitSession& operator=(const RWSplitSession&);
public:
RWSplitSession(RWSplit* instance, MXS_SESSION* session);
/**
* Create a new router session
*
* @param instance Router instance
* @param session The session object
*
* @return New router session
*/
static RWSplitSession* create(RWSplit* router, MXS_SESSION* session);
// TODO: Make member variables private
skygw_chk_t rses_chk_top;
@ -100,6 +109,10 @@ public:
ClientHandleMap ps_handles; /**< Client PS handle to internal ID mapping */
ExecMap exec_map; /**< Map of COM_STMT_EXECUTE statement IDs to Backends */
skygw_chk_t rses_chk_tail;
private:
RWSplitSession(RWSplit* instance, MXS_SESSION* session,
const SRWBackendList& backends, const SRWBackend& master);
};
/** Struct for holding routing related information */