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:
parent
cdb43335a2
commit
3f4d6391b5
@ -107,6 +107,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
test_auth, /**< Authentication */
|
||||
test_default_auth, /**< Default authenticator */
|
||||
test_connection_limit, /**< Connection limit */
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <maxscale/cdefs.h>
|
||||
#include <maxscale/buffer.h>
|
||||
#include <maxscale/jansson.h>
|
||||
|
||||
MXS_BEGIN_DECLS
|
||||
|
||||
@ -169,6 +170,15 @@ typedef struct mxs_protocol
|
||||
*/
|
||||
bool (*established)(struct dcb* );
|
||||
|
||||
/**
|
||||
* Provide JSON formatted diagnostics about a DCB
|
||||
*
|
||||
* @param dcb DCB to diagnose
|
||||
*
|
||||
* @return JSON representation of the DCB
|
||||
*/
|
||||
json_t* (*diagnostics_json)(struct dcb* dcb);
|
||||
|
||||
} MXS_PROTOCOL;
|
||||
|
||||
/**
|
||||
|
@ -3759,5 +3759,12 @@ json_t* dcb_to_json(DCB* dcb)
|
||||
json_object_set_new(obj, "id", json_string(buf));
|
||||
json_object_set_new(obj, "server", json_string(dcb->server->name));
|
||||
|
||||
if (dcb->func.diagnostics_json)
|
||||
{
|
||||
json_t* json = dcb->func.diagnostics_json(dcb);
|
||||
ss_dassert(json);
|
||||
json_object_set_new(obj, "protocol_diagnostics", json);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
@ -89,6 +89,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
cdc_default_auth, /* default authentication */
|
||||
NULL,
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -83,7 +83,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /**< Authentication */
|
||||
httpd_default_auth, /**< Default authenticator */
|
||||
NULL, /**< Connection limit reached */
|
||||
NULL
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -107,6 +107,7 @@ extern "C"
|
||||
NULL, /* Authentication */
|
||||
gw_default_auth, /* Default authenticator */
|
||||
gw_connection_limit, /* Send error connection limit */
|
||||
NULL,
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -185,7 +185,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /**< Authentication */
|
||||
mxsd_default_auth, /**< Default authenticator */
|
||||
NULL, /**< Connection limit reached */
|
||||
NULL
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
@ -104,7 +104,8 @@ MXS_MODULE* MXS_CREATE_MODULE()
|
||||
NULL, /**< Authentication */
|
||||
telnetd_default_auth, /**< Default authenticator */
|
||||
NULL, /**< Connection limit reached */
|
||||
NULL
|
||||
NULL,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static MXS_MODULE info =
|
||||
|
Loading…
x
Reference in New Issue
Block a user