未验证 提交 ef0b45ec 编写于 作者: S Salvatore Sanfilippo 提交者: GitHub

Merge pull request #6497 from oranagra/avoid_replica_traffic

Add config and module API for AvoidReplicaTraffic
...@@ -1900,6 +1900,14 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) { ...@@ -1900,6 +1900,14 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
return flags; return flags;
} }
/* Returns true when the module should avoid actions that cause traffic to replicas.
* This is required during manual failover when waiting for the replica
* to be in perfect sync with the master. Modules doing background operations
* which are not a result of user traffic should check this flag periodically. */
int RM_AvoidReplicaTraffic() {
return clientsArePaused();
}
/* Change the currently selected DB. Returns an error if the id /* Change the currently selected DB. Returns an error if the id
* is out of range. * is out of range.
* *
...@@ -7649,6 +7657,7 @@ void moduleRegisterCoreAPI(void) { ...@@ -7649,6 +7657,7 @@ void moduleRegisterCoreAPI(void) {
REGISTER_API(KeyAtPos); REGISTER_API(KeyAtPos);
REGISTER_API(GetClientId); REGISTER_API(GetClientId);
REGISTER_API(GetContextFlags); REGISTER_API(GetContextFlags);
REGISTER_API(AvoidReplicaTraffic);
REGISTER_API(PoolAlloc); REGISTER_API(PoolAlloc);
REGISTER_API(CreateDataType); REGISTER_API(CreateDataType);
REGISTER_API(ModuleTypeSetValue); REGISTER_API(ModuleTypeSetValue);
......
...@@ -524,6 +524,7 @@ unsigned long long REDISMODULE_API_FUNC(RedisModule_GetClientId)(RedisModuleCtx ...@@ -524,6 +524,7 @@ unsigned long long REDISMODULE_API_FUNC(RedisModule_GetClientId)(RedisModuleCtx
int REDISMODULE_API_FUNC(RedisModule_GetClientInfoById)(void *ci, uint64_t id); int REDISMODULE_API_FUNC(RedisModule_GetClientInfoById)(void *ci, uint64_t id);
int REDISMODULE_API_FUNC(RedisModule_PublishMessage)(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message); int REDISMODULE_API_FUNC(RedisModule_PublishMessage)(RedisModuleCtx *ctx, RedisModuleString *channel, RedisModuleString *message);
int REDISMODULE_API_FUNC(RedisModule_GetContextFlags)(RedisModuleCtx *ctx); int REDISMODULE_API_FUNC(RedisModule_GetContextFlags)(RedisModuleCtx *ctx);
int REDISMODULE_API_FUNC(RedisModule_AvoidReplicaTraffic)();
void *REDISMODULE_API_FUNC(RedisModule_PoolAlloc)(RedisModuleCtx *ctx, size_t bytes); void *REDISMODULE_API_FUNC(RedisModule_PoolAlloc)(RedisModuleCtx *ctx, size_t bytes);
RedisModuleType *REDISMODULE_API_FUNC(RedisModule_CreateDataType)(RedisModuleCtx *ctx, const char *name, int encver, RedisModuleTypeMethods *typemethods); RedisModuleType *REDISMODULE_API_FUNC(RedisModule_CreateDataType)(RedisModuleCtx *ctx, const char *name, int encver, RedisModuleTypeMethods *typemethods);
int REDISMODULE_API_FUNC(RedisModule_ModuleTypeSetValue)(RedisModuleKey *key, RedisModuleType *mt, void *value); int REDISMODULE_API_FUNC(RedisModule_ModuleTypeSetValue)(RedisModuleKey *key, RedisModuleType *mt, void *value);
...@@ -760,6 +761,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int ...@@ -760,6 +761,7 @@ static int RedisModule_Init(RedisModuleCtx *ctx, const char *name, int ver, int
REDISMODULE_GET_API(KeyAtPos); REDISMODULE_GET_API(KeyAtPos);
REDISMODULE_GET_API(GetClientId); REDISMODULE_GET_API(GetClientId);
REDISMODULE_GET_API(GetContextFlags); REDISMODULE_GET_API(GetContextFlags);
REDISMODULE_GET_API(AvoidReplicaTraffic);
REDISMODULE_GET_API(PoolAlloc); REDISMODULE_GET_API(PoolAlloc);
REDISMODULE_GET_API(CreateDataType); REDISMODULE_GET_API(CreateDataType);
REDISMODULE_GET_API(ModuleTypeSetValue); REDISMODULE_GET_API(ModuleTypeSetValue);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册