MXS-1220: Expose module information via the REST API

The modules, their types and default values are exposed via the
/maxscale/modules resource. Currently, only a list of resources can be
exposed as the externally exposed module object (MXS_MODULE) does not have
the name and type information in it.
This commit is contained in:
Markus Mäkelä
2017-05-02 09:54:50 +03:00
parent 73cf7999f2
commit afff5e98b3
4 changed files with 151 additions and 6 deletions

View File

@ -20,6 +20,8 @@
#include <stdint.h>
#include <maxscale/debug.h>
MXS_BEGIN_DECLS
/**
@ -217,4 +219,76 @@ typedef struct mxs_module
/** Name of the symbol that MaxScale will load */
#define MXS_MODULE_SYMBOL_NAME "mxs_get_module_object"
static inline const char* mxs_module_param_type_to_string(enum mxs_module_param_type type)
{
switch (type)
{
case MXS_MODULE_PARAM_COUNT:
return "count";
case MXS_MODULE_PARAM_INT:
return "int";
case MXS_MODULE_PARAM_SIZE:
return "size";
case MXS_MODULE_PARAM_BOOL:
return "bool";
case MXS_MODULE_PARAM_STRING:
return "string";
case MXS_MODULE_PARAM_ENUM:
return "enum";
case MXS_MODULE_PARAM_PATH:
return "path";
case MXS_MODULE_PARAM_SERVICE:
return "service";
case MXS_MODULE_PARAM_SERVER:
return "server";
case MXS_MODULE_PARAM_SERVERLIST:
return "serverlist";
default:
ss_dassert(!true);
return "unknown";
}
}
static inline const char* mxs_module_api_to_string(MXS_MODULE_API type)
{
switch (type)
{
case MXS_MODULE_API_PROTOCOL:
return "protocol";
case MXS_MODULE_API_ROUTER:
return "router";
case MXS_MODULE_API_MONITOR:
return "monitor";
case MXS_MODULE_API_FILTER:
return "filter";
case MXS_MODULE_API_AUTHENTICATOR:
return "authenticator";
case MXS_MODULE_API_QUERY_CLASSIFIER:
return "query_classifier";
default:
ss_dassert(!true);
return "unknown";
}
}
static inline const char* mxs_module_status_to_string(MXS_MODULE_STATUS type)
{
switch (type)
{
case MXS_MODULE_IN_DEVELOPMENT:
return "In development";
case MXS_MODULE_ALPHA_RELEASE:
return "Alpha";
case MXS_MODULE_BETA_RELEASE:
return "Beta";
case MXS_MODULE_GA:
return "GA";
case MXS_MODULE_EXPERIMENTAL:
return "Experimental";
default:
ss_dassert(!true);
return "Unknown";
}
}
MXS_END_DECLS