MXS-553: Add diagnostics_json to protocol API

The protocol now allows protocol modules to return JSON formatted
information about the protocol module internals. Currently this is only
implemented by the mariadbbackend module and it returns the current
connection ID on the backend server.
This commit is contained in:
Markus Mäkelä
2018-05-18 13:53:03 +03:00
parent cdb43335a2
commit 3f4d6391b5
9 changed files with 37 additions and 4 deletions

View File

@ -57,6 +57,7 @@ static void gw_send_proxy_protocol_header(DCB *backend_dcb);
static bool get_ip_string_and_port(struct sockaddr_storage *sa, char *ip, int iplen,
in_port_t *port_out);
static bool gw_connection_established(DCB* dcb);
json_t* gw_json_diagnostics(DCB* dcb);
extern "C"
{
@ -84,7 +85,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
gw_change_user, /* Authentication */
gw_backend_default_auth, /* Default authenticator */
NULL, /* Connection limit reached */
gw_connection_established
gw_connection_established,
gw_json_diagnostics,
};
static MXS_MODULE info =
@ -2199,3 +2201,11 @@ static bool gw_connection_established(DCB* dcb)
(proto->ignore_replies == 0)
&& !proto->stored_query;
}
json_t* gw_json_diagnostics(DCB* dcb)
{
MySQLProtocol* proto = static_cast<MySQLProtocol*>(dcb->protocol);
json_t* obj = json_object();
json_object_set_new(obj, "connection_id", json_integer(proto->thread_id));
return obj;
}