2020-06-09 09:19:11 +00:00
|
|
|
#ifndef ODYSSEY_MODULE_H
|
|
|
|
#define ODYSSEY_MODULE_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Odyssey.
|
|
|
|
*
|
|
|
|
* Scalable PostgreSQL connection pooler.
|
|
|
|
*/
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
#define OD_LOAD_MODULE "od_module"
|
2020-06-09 09:19:11 +00:00
|
|
|
#define od_load_module(handle) (od_module_t *)od_dlsym(handle, OD_LOAD_MODULE)
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
#define OD_MODULE_CB_OK_RETCODE 0
|
2020-06-09 09:19:11 +00:00
|
|
|
#define OD_MODULE_CB_FAIL_RETCODE -1
|
|
|
|
|
2020-06-15 08:26:58 +00:00
|
|
|
typedef int (*module_init_cb)();
|
|
|
|
typedef int (*client_auth_attempt_cb)(od_client_t *c);
|
|
|
|
typedef int (*client_auth_complete_cb)(od_client_t *c, int rc);
|
2020-07-08 06:26:17 +00:00
|
|
|
typedef int (*client_disconnect_cb)(od_client_t *c, od_frontend_status_t s);
|
2020-12-28 10:43:31 +00:00
|
|
|
typedef int (*config_custom_init_cb)(char *user_name, od_config_reader_t *cr,
|
|
|
|
od_token_t *token);
|
2020-06-14 17:02:07 +00:00
|
|
|
typedef int (*module_unload_cb)(void);
|
2020-06-09 09:19:11 +00:00
|
|
|
|
2020-06-15 08:26:58 +00:00
|
|
|
typedef module_init_cb module_init_cb_t;
|
|
|
|
typedef client_auth_attempt_cb client_auth_attempt_cb_t;
|
|
|
|
typedef client_auth_complete_cb client_auth_complete_cb_t;
|
2020-06-09 09:19:11 +00:00
|
|
|
typedef client_disconnect_cb client_disconnect_cb_t;
|
|
|
|
typedef config_custom_init_cb config_custom_init_cb_t;
|
|
|
|
typedef module_unload_cb module_unload_cb_t;
|
|
|
|
|
2020-06-25 06:59:29 +00:00
|
|
|
#define MAX_MODULE_PATH_LEN 2048
|
2020-06-09 09:19:11 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
struct od_module {
|
2020-06-09 09:19:11 +00:00
|
|
|
void *handle;
|
|
|
|
char path[MAX_MODULE_PATH_LEN];
|
|
|
|
|
|
|
|
/* Handlers */
|
|
|
|
/*---------------------------------*/
|
2020-06-15 08:26:58 +00:00
|
|
|
module_init_cb_t module_init_cb;
|
2020-06-09 09:19:11 +00:00
|
|
|
client_auth_attempt_cb_t auth_attempt_cb;
|
2020-06-15 08:26:58 +00:00
|
|
|
client_auth_complete_cb_t auth_complete_cb;
|
2020-06-09 09:19:11 +00:00
|
|
|
client_disconnect_cb_t disconnect_cb;
|
|
|
|
config_custom_init_cb_t config_init_cb;
|
|
|
|
module_unload_cb_t unload_cb;
|
|
|
|
|
|
|
|
/*---------------------------------*/
|
|
|
|
od_list_t link;
|
|
|
|
};
|
2020-06-15 08:26:58 +00:00
|
|
|
|
2020-06-09 09:19:11 +00:00
|
|
|
typedef struct od_module od_module_t;
|
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
void od_modules_init(od_module_t *module);
|
2020-06-09 09:19:11 +00:00
|
|
|
|
2020-12-28 10:43:31 +00:00
|
|
|
int od_target_module_add(od_logger_t *logger, od_module_t *modules,
|
|
|
|
char *target_module_path);
|
|
|
|
int od_target_module_unload(od_logger_t *logger, od_module_t *modules,
|
|
|
|
char *target_module);
|
|
|
|
int od_modules_unload(od_logger_t *logger, od_module_t *modules);
|
2020-06-09 09:19:11 +00:00
|
|
|
// function tio perform "fast" unload all modules,
|
|
|
|
// here we do not wait for module-defined unload callback
|
2020-12-28 10:43:31 +00:00
|
|
|
int od_modules_unload_fast(od_module_t *modules);
|
2020-06-09 09:19:11 +00:00
|
|
|
|
|
|
|
#endif /* ODYSSEY_MODULE_H */
|