Move most readwritesplit functions into classes

Most of the funtionality is now a member function of either the RWSplit or
RWSplitSession class. This removes the need to pass the router and session
parameters to all functions.
This commit is contained in:
Markus Mäkelä
2018-04-03 23:18:57 +03:00
parent ce500d782a
commit 15f15be49d
11 changed files with 360 additions and 470 deletions

View File

@ -12,7 +12,7 @@
*/
#include "readwritesplit.hh"
#include "rwsplit_internal.hh"
#include "rwsplitsession.hh"
#include <strings.h>
#include <string.h>
@ -79,9 +79,8 @@
* @param qtype Query type
* @return bool indicating whether the session can continue
*/
bool handle_target_is_all(route_target_t route_target, RWSplit *inst,
RWSplitSession *rses, GWBUF *querybuf,
int packet_type, uint32_t qtype)
bool RWSplitSession::handle_target_is_all(route_target_t route_target, GWBUF *querybuf,
int packet_type, uint32_t qtype)
{
bool result = false;
@ -105,18 +104,18 @@ bool handle_target_is_all(route_target_t route_target, RWSplit *inst,
if (errbuf)
{
rses->client_dcb->func.write(rses->client_dcb, errbuf);
client_dcb->func.write(client_dcb, errbuf);
result = true;
}
MXS_FREE(query_str);
MXS_FREE(qtype_str);
}
else if (route_session_write(rses, gwbuf_clone(querybuf), packet_type, qtype))
else if (route_session_write(gwbuf_clone(querybuf), packet_type, qtype))
{
result = true;
atomic_add_uint64(&inst->stats().n_all, 1);
atomic_add_uint64(&router->stats().n_all, 1);
}
return result;