Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ruanhaishen
redis
Commits
3170f633
Commit
3170f633
authored
Oct 18, 2019
by
antirez
Browse files
Modules hooks: initial design of data structures.
parent
ed2ba31e
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/module.c
View file @
3170f633
...
@@ -65,7 +65,7 @@ struct RedisModule {
...
@@ -65,7 +65,7 @@ struct RedisModule {
list
*
filters
;
/* List of filters the module has registered. */
list
*
filters
;
/* List of filters the module has registered. */
int
in_call
;
/* RM_Call() nesting level */
int
in_call
;
/* RM_Call() nesting level */
int
options
;
/* Module options and capabilities. */
int
options
;
/* Module options and capabilities. */
RedisModuleInfoFunc
info_cb
;
/*
c
allback for module to add INFO fields. */
RedisModuleInfoFunc
info_cb
;
/*
C
allback for module to add INFO fields. */
};
};
typedef
struct
RedisModule
RedisModule
;
typedef
struct
RedisModule
RedisModule
;
...
@@ -323,6 +323,43 @@ static struct RedisModuleForkInfo {
...
@@ -323,6 +323,43 @@ static struct RedisModuleForkInfo {
#define REDISMODULE_ARGV_NO_AOF (1<<1)
#define REDISMODULE_ARGV_NO_AOF (1<<1)
#define REDISMODULE_ARGV_NO_REPLICAS (1<<2)
#define REDISMODULE_ARGV_NO_REPLICAS (1<<2)
/* Server events hooks data structures and defines: this modules API
* allow modules to subscribe to certain events in Redis, such as
* the start and end of an RDB or AOF save, the change of role in replication,
* and similar other events. */
#define REDISMODULE_EVENT_ID_REPLICATION_ROLE_CHANGED 0
#define REDISMODULE_EVENT_ID_RDB_SAVE_START 1
#define REDISMODULE_EVENT_ID_RDB_SAVE_END 2
#define REDISMODULE_EVENT_ID_AOF_REWRITE_START 3
#define REDISMODULE_EVENT_ID_AOF_REWRITE_END 4
#define REDISMODULE_EVENT_ID_FLUSHDB_START 5
#define REDISMODULE_EVENT_ID_FLUSHDB_END 6
#define REDISMODULE_EVENT_ID_LOADING_START 7
#define REDISMODULE_EVENT_ID_LOADING_END 8
#define REDISMODULE_EVENT_ID_CLIENT_CONNNECTED 9
#define REDISMODULE_EVENT_ID_CLIENT_DISCONNECTED 10
#define REDISMODULE_EVENT_ID_SERVER_SHUTDOWN 11
#define REDISMODULE_EVENT_ID_REPLICA_ONLINE 12
#define REDISMODULE_EVENT_ID_REPLICA_OFFLINE 13
#define REDISMODULE_EVENT_ID_MASTER_LINK_UP 14
#define REDISMODULE_EVENT_ID_MASTER_LINK_DOWN 15
typedef
struct
RedisModuleEvent
{
uint64_t
id
;
/* REDISMODULE_EVENT_ID_... defines. */
uint64_t
dataver
;
/* Version of the structure we pass as 'data'. */
}
RedisModuleEvent
;
typedef
int
(
*
RedisModuleEventCallback
)(
RedisModuleEvent
eid
,
void
*
data
);
typedef
struct
RedisModuleEventListener
{
RedisModule
*
module
;
RedisModuleEvent
event
;
RedisModuleEventCallback
callback
;
}
RedisModuleEventListener
;
list
*
RedisModule_EventListeners
;
/* Global list of all the active events. */
/* --------------------------------------------------------------------------
/* --------------------------------------------------------------------------
* Prototypes
* Prototypes
* -------------------------------------------------------------------------- */
* -------------------------------------------------------------------------- */
...
@@ -5614,6 +5651,9 @@ void moduleInitModulesSystem(void) {
...
@@ -5614,6 +5651,9 @@ void moduleInitModulesSystem(void) {
/* Create the timers radix tree. */
/* Create the timers radix tree. */
Timers
=
raxNew
();
Timers
=
raxNew
();
/* Setup the event listeners data structures. */
RedisModule_EventListeners
=
listCreate
();
/* Our thread-safe contexts GIL must start with already locked:
/* Our thread-safe contexts GIL must start with already locked:
* it is just unlocked when it's safe. */
* it is just unlocked when it's safe. */
pthread_mutex_lock
(
&
moduleGIL
);
pthread_mutex_lock
(
&
moduleGIL
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment