MXS-1220: Add JSON return value to diagnostics entry points
The modules that implement a diagnostics entry point now return a JSON type object. This removes the need to format data inside the modules. The module implementations of these are not yet complete which means that MaxScale will fail to compile.
This commit is contained in:
committed by
Markus Mäkelä
parent
94ebef0703
commit
bbe0620944
@ -206,7 +206,12 @@ dprintAllFilters(DCB *dcb)
|
||||
}
|
||||
if (ptr->obj && ptr->filter)
|
||||
{
|
||||
ptr->obj->diagnostics(ptr->filter, NULL, dcb);
|
||||
json_t* json = ptr->obj->diagnostics(ptr->filter, NULL);
|
||||
|
||||
if (json)
|
||||
{
|
||||
json_decref(json);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -241,7 +246,12 @@ dprintFilter(DCB *dcb, const MXS_FILTER_DEF *filter)
|
||||
}
|
||||
if (filter->obj && filter->filter)
|
||||
{
|
||||
filter->obj->diagnostics(filter->filter, NULL, dcb);
|
||||
json_t* json = filter->obj->diagnostics(filter->filter, NULL);
|
||||
|
||||
if (json)
|
||||
{
|
||||
json_decref(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,8 +497,12 @@ json_t* filter_to_json(const MXS_FILTER_DEF* filter)
|
||||
|
||||
if (filter->obj && filter->filter)
|
||||
{
|
||||
// TODO: Add filter diagnostics
|
||||
//filter->obj->diagnostics(filter->filter, NULL, dcb);
|
||||
json_t* diag = filter->obj->diagnostics(filter->filter, NULL);
|
||||
|
||||
if (diag)
|
||||
{
|
||||
json_object_set_new(rval, "filter_diagnostics", diag);
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
||||
@ -482,7 +482,12 @@ monitorShow(DCB *dcb, MXS_MONITOR *monitor)
|
||||
{
|
||||
if (monitor->module->diagnostics)
|
||||
{
|
||||
monitor->module->diagnostics(dcb, monitor);
|
||||
json_t* json = monitor->module->diagnostics(monitor);
|
||||
|
||||
if (json)
|
||||
{
|
||||
json_decref(json);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1563,8 +1568,12 @@ json_t* monitor_to_json(const MXS_MONITOR* monitor)
|
||||
|
||||
if (monitor->handle && monitor->module->diagnostics)
|
||||
{
|
||||
// TODO: Add monitor diagnostics
|
||||
//monitor->module->diagnostics(dcb, monitor);
|
||||
json_t* diag = monitor->module->diagnostics(monitor);
|
||||
|
||||
if (diag)
|
||||
{
|
||||
json_object_set_new(rval, "monitor_diagnostics", diag);
|
||||
}
|
||||
}
|
||||
|
||||
return rval;
|
||||
|
||||
@ -1439,7 +1439,12 @@ void dprintService(DCB *dcb, SERVICE *service)
|
||||
}
|
||||
if (service->router && service->router_instance)
|
||||
{
|
||||
service->router->diagnostics(service->router_instance, dcb);
|
||||
json_t* json = service->router->diagnostics(service->router_instance);
|
||||
|
||||
if (json)
|
||||
{
|
||||
json_decref(json);
|
||||
}
|
||||
}
|
||||
dcb_printf(dcb, "\tStarted: %s",
|
||||
asctime_r(localtime_r(&service->stats.started, &result), timebuf));
|
||||
@ -2317,7 +2322,12 @@ void service_print_users(DCB *dcb, const SERVICE *service)
|
||||
{
|
||||
if (port->listener && port->listener->authfunc.diagnostic)
|
||||
{
|
||||
port->listener->authfunc.diagnostic(dcb, port);
|
||||
json_t* json = port->listener->authfunc.diagnostic(port);
|
||||
|
||||
if (json)
|
||||
{
|
||||
json_decref(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2382,8 +2392,12 @@ json_t* service_to_json(const SERVICE* service)
|
||||
|
||||
if (service->router && service->router_instance)
|
||||
{
|
||||
// TODO: Add router diagnostics
|
||||
//service->router->diagnostics(service->router_instance, dcb);
|
||||
json_t* diag = service->router->diagnostics(service->router_instance);
|
||||
|
||||
if (diag)
|
||||
{
|
||||
json_object_set_new(rval, "router_diagnostics", diag);
|
||||
}
|
||||
}
|
||||
|
||||
struct tm result;
|
||||
|
||||
@ -530,9 +530,13 @@ dprintSession(DCB *dcb, MXS_SESSION *print_session)
|
||||
{
|
||||
dcb_printf(dcb, "\tFilter: %s\n",
|
||||
print_session->filters[i].filter->name);
|
||||
print_session->filters[i].filter->obj->diagnostics(print_session->filters[i].instance,
|
||||
print_session->filters[i].session,
|
||||
dcb);
|
||||
json_t* json = print_session->filters[i].filter->obj->diagnostics(print_session->filters[i].instance,
|
||||
print_session->filters[i].session);
|
||||
|
||||
if (json)
|
||||
{
|
||||
json_decref(json);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user