MXS-1848 Introduce a specific monitor type

Instead of using void there's now a MXS_SPECIFIC_MONITOR struct
from which monitor specific types can be derived. This change
does not bring about other benefits than a bit of clarity but
this is the first step in clearing up the monitor API.
This commit is contained in:
Johan Wikman
2018-05-04 10:02:06 +03:00
parent 1f6cc6db8a
commit d4008f7b28
11 changed files with 34 additions and 30 deletions

View File

@ -38,7 +38,7 @@ MXS_MODULE info =
};
/*lint +e14 */
static void *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *);
static MXS_SPECIFIC_MONITOR *startMonitor(MXS_MONITOR *, const MXS_CONFIG_PARAMETER *);
static void stopMonitor(MXS_MONITOR *);
static void diagnostics(DCB *, const MXS_MONITOR *);
static json_t* diagnostics_json(const MXS_MONITOR *);
@ -114,7 +114,7 @@ MXS_MODULE* MXS_CREATE_MODULE()
* @param arg The current handle - NULL if first start
* @return A handle to use when interacting with the monitor
*/
static void *
static MXS_SPECIFIC_MONITOR *
startMonitor(MXS_MONITOR *mon, const MXS_CONFIG_PARAMETER *params)
{
MM_MONITOR *handle = static_cast<MM_MONITOR*>(mon->handle);

View File

@ -33,12 +33,10 @@
* @file mmmon.h - The Multi-Master monitor
*/
MXS_BEGIN_DECLS
/**
* The handle for an instance of a Multi-Master Monitor module
*/
typedef struct
struct MM_MONITOR : public MXS_SPECIFIC_MONITOR
{
THREAD thread; /**< Monitor thread */
int shutdown; /**< Flag to shutdown the monitor thread */
@ -49,8 +47,6 @@ typedef struct
char* script; /*< Script to call when state changes occur on servers */
uint64_t events; /*< enabled events */
MXS_MONITOR* monitor;
} MM_MONITOR;
MXS_END_DECLS
};
#endif