Files
MaxScale/server/include/router.h
VilhoRaatikka 889bdd4f8c In dcb.c:dcb_close DCB is removed either before or after the call dcb->func.close. Since mysql backend protocol sends COM_QUIT and thus, writes to backend DCB, it is kept in DCB_STATE_POLLING until the write is completed.
dcb.h: define ERRHAND temporarily since changes are still behind that macro
Defined two error handling actions in router.h: ERRACT_NEW_COMMECTION and ERRACT_REPLY_CLIENT.
Failed database is logged at expanding frequence to error and to message log due changes in mysql_mon.c. Added two new members in MONITOR_SERVERS: mon_err_count, and mon_prev_status so that each backend can be treated individually.

Error handling: if mysql_backend.c:dcb_read fails, router's handleError is called instead of closing session.
	If mysql_client.c:SESSION_ROUTE_QUERY fails router's handleError is called instead of sending error to client.

	readwritesplit.c:select_connect_backend_servers is modified so that in can be called during active router session. When called, it attempts to find one master and maximum number of configured slaves in correct state if necessary.
	When handleError needs to replace failed unit it now calls select_connect_backend_servers.
2014-06-08 19:36:12 +03:00

107 lines
3.5 KiB
C

#ifndef _ROUTER_H
#define _ROUTER_H
/*
* This file is distributed as part of the SkySQL Gateway. It is free
* software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation,
* version 2.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
* details.
*
* You should have received a copy of the GNU General Public License along with
* this program; if not, write to the Free Software Foundation, Inc., 51
* Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Copyright SkySQL Ab 2013
*/
/**
* @file router.h - The query router interface mechanisms
*
* Revision History
*
* Date Who Description
* 14/06/2013 Mark Riddoch Initial implementation
* 26/06/2013 Mark Riddoch Addition of router options
* and the diagnostic entry point
* 15/07/2013 Massimiliano Pinto Added clientReply entry point
* 16/07/2013 Massimiliano Pinto Added router commands values
* 22/10/2013 Massimiliano Pinto Added router errorReply entry point
*
*/
#include <service.h>
#include <session.h>
#include <buffer.h>
#include <stdint.h>
/**
* The ROUTER handle points to module specific data, so the best we can do
* is to make it a void * externally.
*/
typedef void *ROUTER;
/**
* @verbatim
* The "module object" structure for a query router module
*
* The entry points are:
* createInstance Called by the service to create a new
* instance of the query router
* newSession Called to create a new user session
* within the query router
* closeSession Called when a session is closed
* routeQuery Called on each query that requires
* routing
* diagnostics Called to force the router to print
* diagnostic output
* clientReply Called to reply to client the data from one or all backends
* errorReply Called to reply to client errors with optional closeSession or
* make a request for a new backend connection
*
* @endverbatim
*
* @see load_module
*/
typedef struct router_object {
ROUTER *(*createInstance)(SERVICE *service, char **options);
void *(*newSession)(ROUTER *instance, SESSION *session);
void (*closeSession)(ROUTER *instance, void *router_session);
void (*freeSession)(ROUTER *instance, void *router_session);
int (*routeQuery)(ROUTER *instance, void *router_session, GWBUF *queue);
void (*diagnostics)(ROUTER *instance, DCB *dcb);
void (*clientReply)(ROUTER* instance, void* router_session, GWBUF* queue, DCB *backend_dcb);
void (*handleError)(
ROUTER* instance,
void* router_session,
char* message,
DCB *backend_dcb,
int action,
bool* succp);
uint8_t (*getCapabilities)(ROUTER *instance, void* router_session);
} ROUTER_OBJECT;
/**
* The router module API version. Any change that changes the router API
* must update these versions numbers in accordance with the rules in
* modinfo.h.
*/
#define ROUTER_VERSION { 1, 0, 0 }
typedef enum router_capability_t {
RCAP_TYPE_UNDEFINED = 0,
RCAP_TYPE_STMT_INPUT = (1 << 0),
RCAP_TYPE_PACKET_INPUT = (1 << 1)
} router_capability_t;
typedef enum error_action {
ERRACT_NEW_CONNECTION = 0x001,
ERRACT_REPLY_CLIENT = 0x002
} error_action_t;
#endif