Move module object inside MODULE_INFO

This allows modules to only expose one entry point with a consistent
signature. In the future, this could be used to implement declarations of
module parameters.
This commit is contained in:
Markus Mäkelä
2017-01-03 14:04:20 +02:00
parent 6c53999c97
commit ae0577c695
53 changed files with 1346 additions and 1483 deletions

View File

@ -58,7 +58,6 @@
#define AVRO_TASK_DELAY_MAX 15
static char *version_str = "V1.0.0";
static const char* avro_task_name = "binlog_to_avro";
static const char* index_task_name = "avro_indexing";
static const char* avro_index_name = "avro.index";
@ -96,35 +95,9 @@ void avro_index_file(AVRO_INSTANCE *router, const char* path);
void avro_update_index(AVRO_INSTANCE* router);
static bool conversion_task_ctl(AVRO_INSTANCE *inst, bool start);
/** The module object definition */
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
errorReply,
getCapabilities,
NULL
};
static SPINLOCK instlock;
static AVRO_INSTANCE *instances;
/**
* Implementation of the mandatory version entry point
*
* @return version string of the module
*/
char *
version()
{
return version_str;
}
bool avro_handle_convert(const MODULECMD_ARG *args)
{
bool rval = false;
@ -145,25 +118,6 @@ bool avro_handle_convert(const MODULECMD_ARG *args)
return rval;
}
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialized avrorouter module %s.\n", version_str);
spinlock_init(&instlock);
instances = NULL;
modulecmd_arg_type_t args[] =
{
{ MODULECMD_ARG_SERVICE, "The avrorouter service" },
{ MODULECMD_ARG_STRING, "Action, whether to 'start' or 'stop' the conversion process" }
};
modulecmd_register_command("avrorouter", "convert", avro_handle_convert, 2, args);
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -172,10 +126,43 @@ ModuleInit()
*
* @return The module object
*/
ROUTER_OBJECT *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
spinlock_init(&instlock);
instances = NULL;
static modulecmd_arg_type_t args[] =
{
{ MODULECMD_ARG_SERVICE, "The avrorouter service" },
{ MODULECMD_ARG_STRING, "Action, whether to 'start' or 'stop' the conversion process" }
};
modulecmd_register_command("avrorouter", "convert", avro_handle_convert, 2, args);
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
errorReply,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"Binlogrouter",
"V1.0.0",
&MyObject
};
return &info;
}
/**

View File

@ -85,8 +85,6 @@
#include <uuid/uuid.h>
#include <maxscale/alloc.h>
static char *version_str = "V2.1.0";
/* The router entry points */
static ROUTER *createInstance(SERVICE *service, char **options);
static void free_instance(ROUTER_INSTANCE *instance);
@ -119,21 +117,6 @@ bool blr_extract_key(const char *linebuf, int nline, ROUTER_INSTANCE *router);
bool blr_get_encryption_key(ROUTER_INSTANCE *router);
int blr_parse_key_file(ROUTER_INSTANCE *router);
/** The module object definition */
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
errorReply,
getCapabilities,
destroyInstance
};
static void stats_func(void *);
static bool rses_begin_locked_router_action(ROUTER_SLAVE *);
@ -143,29 +126,6 @@ GWBUF *blr_cache_read_response(ROUTER_INSTANCE *router, char *response);
static SPINLOCK instlock;
static ROUTER_INSTANCE *instances;
/**
* Implementation of the mandatory version entry point
*
* @return version string of the module
*/
char *
version()
{
return version_str;
}
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise binlog router module %s.\n", version_str);
spinlock_init(&instlock);
instances = NULL;
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -174,10 +134,37 @@ ModuleInit()
*
* @return The module object
*/
ROUTER_OBJECT *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
MXS_NOTICE("Initialise binlog router module.");
spinlock_init(&instlock);
instances = NULL;
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
errorReply,
getCapabilities,
destroyInstance
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"Binlogrouter",
"V2.1.0",
&MyObject
};
return &info;
}
/**

View File

@ -40,16 +40,6 @@
#include <debugcli.h>
#include <maxscale/log_manager.h>
MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"The admin user interface",
"V1.0.0"
};
/* The router entry points */
static ROUTER *createInstance(SERVICE *service, char **options);
static void *newSession(ROUTER *instance, SESSION *session);
@ -59,38 +49,11 @@ static int execute(ROUTER *instance, void *router_session, GWBUF *queue);
static void diagnostics(ROUTER *instance, DCB *dcb);
static uint64_t getCapabilities(void);
/** The module object definition */
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
execute,
diagnostics,
NULL,
NULL,
getCapabilities,
NULL
};
extern int execute_cmd(CLI_SESSION *cli);
static SPINLOCK instlock;
static CLI_INSTANCE *instances;
/**
* The module initialisation routine, called when the module
* is first loaded.
*/
void
ModuleInit()
{
MXS_NOTICE("Initialise CLI router module");
spinlock_init(&instlock);
instances = NULL;
}
/**
* The module entry point routine. It is this routine that
* must populate the structure that is referred to as the
@ -99,10 +62,37 @@ ModuleInit()
*
* @return The module object
*/
ROUTER_OBJECT *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
MXS_NOTICE("Initialise CLI router module");
spinlock_init(&instlock);
instances = NULL;
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
execute,
diagnostics,
NULL,
NULL,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"The admin user interface",
"V1.0.0",
&MyObject
};
return &info;
}
/**

View File

@ -39,16 +39,6 @@
#include <debugcli.h>
#include <maxscale/log_manager.h>
MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"The debug user interface",
"V1.1.1"
};
/* The router entry points */
static ROUTER *createInstance(SERVICE *service, char **options);
static void *newSession(ROUTER *instance, SESSION *session);
@ -58,21 +48,6 @@ static int execute(ROUTER *instance, void *router_session, GWBUF *queue);
static void diagnostics(ROUTER *instance, DCB *dcb);
static uint64_t getCapabilities ();
/** The module object definition */
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
execute,
diagnostics,
NULL,
NULL,
getCapabilities,
NULL
};
extern int execute_cmd(CLI_SESSION *cli);
static SPINLOCK instlock;
@ -86,13 +61,37 @@ static CLI_INSTANCE *instances;
*
* @return The module object
*/
ROUTER_OBJECT *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
MXS_NOTICE("Initialise debug CLI router module.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
execute,
diagnostics,
NULL,
NULL,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"The debug user interface",
"V1.1.1",
&MyObject
};
return &info;
}
/**

View File

@ -51,16 +51,6 @@
#include <maxscale/secrets.h>
#include <maxscale/users.h>
MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_ALPHA_RELEASE,
ROUTER_VERSION,
"The MaxScale Information Schema",
"V1.0.0"
};
extern char *create_hex_sha1_sha1_passwd(char *passwd);
static int maxinfo_statistics(INFO_INSTANCE *, INFO_SESSION *, GWBUF *);
@ -84,21 +74,6 @@ static void handleError(ROUTER *instance,
error_action_t action,
bool *succp);
/** The module object definition */
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
execute,
diagnostics,
NULL,
handleError,
getCapabilities,
NULL
};
static SPINLOCK instlock;
static INFO_INSTANCE *instances;
@ -110,13 +85,37 @@ static INFO_INSTANCE *instances;
*
* @return The module object
*/
ROUTER_OBJECT *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
MXS_NOTICE("Initialise MaxInfo router module.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
execute,
diagnostics,
NULL,
handleError,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_ALPHA_RELEASE,
ROUTER_VERSION,
"The MaxScale Information Schema",
"V1.0.0",
&MyObject
};
return &info;
}
/**

View File

@ -90,15 +90,6 @@
#include <maxscale/modutil.h>
MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"A connection based router to load balance based on connections",
"V1.1.0"
};
/* The router entry points */
static ROUTER *createInstance(SERVICE *service, char **options);
static void *newSession(ROUTER *instance, SESSION *session);
@ -111,29 +102,11 @@ static void clientReply(ROUTER *instance, void *router_session, GWBUF *queue,
static void handleError(ROUTER *instance, void *router_session, GWBUF *errbuf,
DCB *problem_dcb, error_action_t action, bool *succp);
static uint64_t getCapabilities(void);
/** The module object definition */
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
handleError,
getCapabilities,
NULL
};
static bool rses_begin_locked_router_action(ROUTER_CLIENT_SES* rses);
static void rses_end_locked_router_action(ROUTER_CLIENT_SES* rses);
static SERVER_REF *get_root_master(SERVER_REF *servers);
static int handle_state_switch(DCB* dcb, DCB_REASON reason, void * routersession);
static SPINLOCK instlock;
static ROUTER_INSTANCE *instances;
@ -145,13 +118,37 @@ static ROUTER_INSTANCE *instances;
*
* @return The module object
*/
ROUTER_OBJECT *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
MXS_NOTICE("Initialise readconnroute router module.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
handleError,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_GA,
ROUTER_VERSION,
"A connection based router to load balance based on connections",
"V1.1.0",
&MyObject
};
return &info;
}
static inline void free_readconn_instance(ROUTER_INSTANCE *router)

View File

@ -28,13 +28,6 @@
#include <maxscale/modutil.h>
#include <maxscale/alloc.h>
MODULE_INFO info =
{
MODULE_API_ROUTER, MODULE_GA, ROUTER_VERSION,
"A Read/Write splitting router for enhancement read scalability",
"V1.1.0"
};
/**
* @file readwritesplit.c The entry points for the read/write query splitting
* router module.
@ -93,20 +86,6 @@ static uint64_t getCapabilities(void);
* make it easier to track the connection between calls and functions.
*/
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
handleError,
getCapabilities,
NULL
};
/*
* Declaration of functions that are used only within this module, and are
* not part of the API.
@ -134,10 +113,32 @@ static bool create_backends(ROUTER_CLIENT_SES *rses, backend_ref_t** dest, int*
*
* @return The module object
*/
ROUTER_OBJECT *GetModuleObject()
MODULE_INFO *GetModuleObject()
{
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostics,
clientReply,
handleError,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER, MODULE_GA, ROUTER_VERSION,
"A Read/Write splitting router for enhancement read scalability",
"V1.1.0",
&MyObject
};
MXS_NOTICE("Initializing statement-based read/write split router module.");
return &MyObject;
return &info;
}
/*

View File

@ -40,16 +40,6 @@
/** Hashtable size for the per user shard maps */
#define SCHEMAROUTER_USERHASH_SIZE 10
MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_BETA_RELEASE,
ROUTER_VERSION,
"A database sharding router for simple sharding",
"V1.0.0"
};
/**
* @file schemarouter.c The entry points for the simple sharding
* router module.
@ -100,20 +90,6 @@ static bool get_shard_dcb(DCB** dcb,
ROUTER_CLIENT_SES* rses,
char* name);
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostic,
clientReply,
handleError,
getCapabilities,
NULL
};
static bool rses_begin_locked_router_action(ROUTER_CLIENT_SES* rses);
static void rses_end_locked_router_action(ROUTER_CLIENT_SES* rses);
static void mysql_sescmd_done(mysql_sescmd_t* sescmd);
@ -615,12 +591,37 @@ bool check_shard_status(ROUTER_INSTANCE* router, char* shard)
*
* @return The module object
*/
ROUTER_OBJECT* GetModuleObject()
MODULE_INFO* GetModuleObject()
{
MXS_NOTICE("Initializing Schema Sharding Router.");
spinlock_init(&instlock);
instances = NULL;
return &MyObject;
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostic,
clientReply,
handleError,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_BETA_RELEASE,
ROUTER_VERSION,
"A database sharding router for simple sharding",
"V1.0.0",
&MyObject
};
return &info;
}
/**

View File

@ -15,15 +15,6 @@
#include <maxscale/router.h>
#include <maxscale/modinfo.h>
MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_IN_DEVELOPMENT,
ROUTER_VERSION,
"A test router - not for use in real systems",
"V1.0.0"
};
static ROUTER *createInstance(SERVICE *service, char **options);
static void *newSession(ROUTER *instance, SESSION *session);
static void closeSession(ROUTER *instance, void *session);
@ -39,20 +30,6 @@ static void handleError(ROUTER *instance,
error_action_t action,
bool *succp);
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostic,
clientReply,
handleError,
getCapabilities,
NULL
};
typedef struct
{
} TESTROUTER;
@ -69,10 +46,33 @@ typedef struct
*
* @return The module object
*/
ROUTER_OBJECT *
GetModuleObject()
MODULE_INFO* GetModuleObject()
{
return &MyObject;
static ROUTER_OBJECT MyObject =
{
createInstance,
newSession,
closeSession,
freeSession,
routeQuery,
diagnostic,
clientReply,
handleError,
getCapabilities,
NULL
};
static MODULE_INFO info =
{
MODULE_API_ROUTER,
MODULE_IN_DEVELOPMENT,
ROUTER_VERSION,
"A test router - not for use in real systems",
"V1.0.0",
&MyObject
};
return &info;
}
/**