diff options
Diffstat (limited to 'src/redismodule.h')
-rw-r--r-- | src/redismodule.h | 67 |
1 files changed, 35 insertions, 32 deletions
diff --git a/src/redismodule.h b/src/redismodule.h index 0bc6d2c3e..02cfa9586 100644 --- a/src/redismodule.h +++ b/src/redismodule.h @@ -163,73 +163,76 @@ typedef uint64_t RedisModuleTimerID; #define REDISMODULE_OPTIONS_HANDLE_IO_ERRORS (1<<0) /* Server events definitions. */ -#define REDISMODULE_EVENT_ID_REPLICATION_ROLE_CHANGED 0 -#define REDISMODULE_EVENT_ID_PERSISTENCE 1 -#define REDISMODULE_EVENT_ID_FLUSHDB 2 -#define REDISMODULE_EVENT_ID_LOADING 3 -#define REDISMODULE_EVENT_ID_CLIENT_CHANGE 4 -#define REDISMODULE_EVENT_ID_SHUTDOWN 5 -#define REDISMODULE_EVENT_ID_REPLICA_CHANGE 6 -#define REDISMODULE_EVENT_ID_MASTER_LINK_CHANGE 7 +#define REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED 0 +#define REDISMODULE_EVENT_PERSISTENCE 1 +#define REDISMODULE_EVENT_FLUSHDB 2 +#define REDISMODULE_EVENT_LOADING 3 +#define REDISMODULE_EVENT_CLIENT_CHANGE 4 +#define REDISMODULE_EVENT_SHUTDOWN 5 +#define REDISMODULE_EVENT_REPLICA_CHANGE 6 +#define REDISMODULE_EVENT_MASTER_LINK_CHANGE 7 typedef struct RedisModuleEvent { - uint64_t id; /* REDISMODULE_EVENT_ID_... defines. */ + uint64_t id; /* REDISMODULE_EVENT_... defines. */ uint64_t dataver; /* Version of the structure we pass as 'data'. */ } RedisModuleEvent; -RedisModuleEvent +struct RedisModuleCtx; +typedef int (*RedisModuleEventCallback)(struct RedisModuleCtx *ctx, RedisModuleEvent eid, uint64_t subevent, void *data); + +static RedisModuleEvent RedisModuleEvent_ReplicationRoleChanged = { - REDISMODULE_EVENT_ID_REPLICATION_ROLE_CHANGED, + REDISMODULE_EVENT_REPLICATION_ROLE_CHANGED, 1 }, RedisModuleEvent_Persistence = { - REDISMODULE_EVENT_ID_PERSISTENCE, + REDISMODULE_EVENT_PERSISTENCE, 1 }, RedisModuleEvent_FlushDB = { - REDISMODULE_EVENT_ID_FLUSHDB, + REDISMODULE_EVENT_FLUSHDB, 1 }, RedisModuleEvent_Loading = { - REDISMODULE_EVENT_ID_LOADING, + REDISMODULE_EVENT_LOADING, 1 }, RedisModuleEvent_ClientChange = { - REDISMODULE_EVENT_ID_CLIENT_CHANGE, + REDISMODULE_EVENT_CLIENT_CHANGE, 1 }, RedisModuleEvent_Shutdown = { - REDISMODULE_EVENT_ID_SHUTDOWN, + REDISMODULE_EVENT_SHUTDOWN, 1 }, RedisModuleEvent_ReplicaChange = { - REDISMODULE_EVENT_ID_REPLICA_CHANGE, + REDISMODULE_EVENT_REPLICA_CHANGE, 1 }, RedisModuleEvent_MasterLinkChange = { - REDISMODULE_EVENT_ID_MASTER_LINK_CHANGE, + REDISMODULE_EVENT_MASTER_LINK_CHANGE, 1 }; -typedef int (*RedisModuleEventCallback)(struct RedisModuleCtx *ctx, RedisModuleEvent eid, uint64_t subevent, void *data); - /* Those are values that are used for the 'subevent' callback argument. */ -#define REDISMODULE_EVENT_PERSISTENCE_RDB_START 0 -#define REDISMODULE_EVENT_PERSISTENCE_RDB_END 1 -#define REDISMODULE_EVENT_PERSISTENCE_AOF_START 2 -#define REDISMODULE_EVENT_PERSISTENCE_AOF_END 3 +#define REDISMODULE_SUBEVENT_PERSISTENCE_RDB_START 0 +#define REDISMODULE_SUBEVENT_PERSISTENCE_RDB_END 1 +#define REDISMODULE_SUBEVENT_PERSISTENCE_AOF_START 2 +#define REDISMODULE_SUBEVENT_PERSISTENCE_AOF_END 3 -#define REDISMODULE_EVENT_LOADING_START 0 -#define REDISMODULE_EVENT_LOADING_END 1 +#define REDISMODULE_SUBEVENT_LOADING_RDB_START 0 +#define REDISMODULE_SUBEVENT_LOADING_RDB_END 1 +#define REDISMODULE_SUBEVENT_LOADING_AOF_START 2 +#define REDISMODULE_SUBEVENT_LOADING_AOF_END 3 -#define REDISMODULE_EVENT_CLIENT_CHANGE_CONNECTED 0 -#define REDISMODULE_EVENT_CLIENT_CHANGE_DISCONNECTED 1 +#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_CONNECTED 0 +#define REDISMODULE_SUBEVENT_CLIENT_CHANGE_DISCONNECTED 1 -#define REDISMODULE_EVENT_MASTER_LINK_UP 0 -#define REDISMODULE_EVENT_MASTER_LINK_DOWN 1 +#define REDISMODULE_SUBEVENT_MASTER_LINK_UP 0 +#define REDISMODULE_SUBEVENT_MASTER_LINK_DOWN 1 -#define REDISMODULE_EVENT_REPLICA_CHANGE_CONNECTED 0 -#define REDISMODULE_EVENT_REPLICA_CHANGE_DISCONNECTED 1 +#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_CONNECTED 0 +#define REDISMODULE_SUBEVENT_REPLICA_CHANGE_DISCONNECTED 1 /* RedisModuleClientInfo flags. */ #define REDISMODULE_CLIENTINFO_FLAG_SSL (1<<0) |