summaryrefslogtreecommitdiff
path: root/src/module.c
diff options
context:
space:
mode:
authorSalvatore Sanfilippo <antirez@gmail.com>2019-12-18 17:06:05 +0100
committerGitHub <noreply@github.com>2019-12-18 17:06:05 +0100
commitef0b45ece8ee629dc2234f9061e0b28f9159df55 (patch)
tree917d076c5cf85bb96f6007951a5454834d326e79 /src/module.c
parent5a72c5058c27cdc778cde8f61d16691b11a6adc5 (diff)
parentb5f3247ca55424d57d77efe51bedd1fb3861c8c0 (diff)
downloadredis-ef0b45ece8ee629dc2234f9061e0b28f9159df55.tar.gz
Merge pull request #6497 from oranagra/avoid_replica_traffic
Add config and module API for AvoidReplicaTraffic
Diffstat (limited to 'src/module.c')
-rw-r--r--src/module.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/module.c b/src/module.c
index 1fda29625..f6f4ef2b9 100644
--- a/src/module.c
+++ b/src/module.c
@@ -1900,6 +1900,14 @@ int RM_GetContextFlags(RedisModuleCtx *ctx) {
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
* is out of range.
*
@@ -7649,6 +7657,7 @@ void moduleRegisterCoreAPI(void) {
REGISTER_API(KeyAtPos);
REGISTER_API(GetClientId);
REGISTER_API(GetContextFlags);
+ REGISTER_API(AvoidReplicaTraffic);
REGISTER_API(PoolAlloc);
REGISTER_API(CreateDataType);
REGISTER_API(ModuleTypeSetValue);