summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorantirez <antirez@gmail.com>2018-09-19 11:20:52 +0200
committerantirez <antirez@gmail.com>2018-09-19 11:20:52 +0200
commit744fe7f348c82a6f55aab43f140a540d298747cf (patch)
tree40ce3e30e24cf7560be242611983c68733a7df35
parent7cdf272d46ad9b658ef8f5d8485af0eeb17cae6d (diff)
downloadredis-744fe7f348c82a6f55aab43f140a540d298747cf.tar.gz
Module cluster flags: initial vars / defines added.
-rw-r--r--src/cluster.c4
-rw-r--r--src/cluster.h7
-rw-r--r--src/redismodule.h4
-rw-r--r--src/server.c1
-rw-r--r--src/server.h4
5 files changed, 20 insertions, 0 deletions
diff --git a/src/cluster.c b/src/cluster.c
index 421e678bb..ad48641ec 100644
--- a/src/cluster.c
+++ b/src/cluster.c
@@ -5438,6 +5438,10 @@ clusterNode *getNodeByQuery(client *c, struct redisCommand *cmd, robj **argv, in
/* Set error code optimistically for the base case. */
if (error_code) *error_code = CLUSTER_REDIR_NONE;
+ /* Modules can turn off Redis Cluster redirection: this is useful
+ * when writing a module that implements a completely different
+ * distributed system. */
+
/* We handle all the cases as if they were EXEC commands, so we have
* a common code path for everything */
if (cmd->proc == execCommand) {
diff --git a/src/cluster.h b/src/cluster.h
index 6f9954d24..68d7af3a4 100644
--- a/src/cluster.h
+++ b/src/cluster.h
@@ -100,6 +100,13 @@ typedef struct clusterLink {
#define CLUSTERMSG_TYPE_MODULE 9 /* Module cluster API message. */
#define CLUSTERMSG_TYPE_COUNT 10 /* Total number of message types. */
+/* Flags that a module can set in order to prevent certain Redis Cluster
+ * features to be enabled. Useful when implementing a different distributed
+ * system on top of Redis Cluster message bus, using modules. */
+#define MODULE_CLUSTER_FLAG_NONE 0
+#define MODULE_CLUSTER_FLAG_NO_FAILOVER (1<<1)
+#define MODULE_CLUSTER_FLAG_NO_REDIRECTION (1<<2)
+
/* This structure represent elements of node->fail_reports. */
typedef struct clusterNodeFailReport {
struct clusterNode *node; /* Node reporting the failure condition. */
diff --git a/src/redismodule.h b/src/redismodule.h
index 47ecb1308..d37865643 100644
--- a/src/redismodule.h
+++ b/src/redismodule.h
@@ -117,6 +117,10 @@
#define REDISMODULE_NODE_FAIL (1<<4)
#define REDISMODULE_NODE_NOFAILOVER (1<<5)
+#define REDISMODULE_CLUSTER_FLAG_NONE 0
+#define REDISMODULE_CLUSTER_FLAG_NO_FAILOVER (1<<1)
+#define REDISMODULE_CLUSTER_FLAG_NO_REDIRECTION (1<<2)
+
#define REDISMODULE_NOT_USED(V) ((void) V)
/* This type represents a timer handle, and is returned when a timer is
diff --git a/src/server.c b/src/server.c
index db52f5fc1..dee18fa6c 100644
--- a/src/server.c
+++ b/src/server.c
@@ -1621,6 +1621,7 @@ void initServerConfig(void) {
server.cluster_announce_ip = CONFIG_DEFAULT_CLUSTER_ANNOUNCE_IP;
server.cluster_announce_port = CONFIG_DEFAULT_CLUSTER_ANNOUNCE_PORT;
server.cluster_announce_bus_port = CONFIG_DEFAULT_CLUSTER_ANNOUNCE_BUS_PORT;
+ server.cluster_module_flags = MODULE_CLUSTER_FLAG_NONE;
server.migrate_cached_sockets = dictCreate(&migrateCacheDictType,NULL);
server.next_client_id = 1; /* Client IDs, start from 1 .*/
server.loading_process_events_interval_bytes = (1024*1024*2);
diff --git a/src/server.h b/src/server.h
index 8b10701de..4c4c0ce55 100644
--- a/src/server.h
+++ b/src/server.h
@@ -1232,6 +1232,10 @@ struct redisServer {
char *cluster_announce_ip; /* IP address to announce on cluster bus. */
int cluster_announce_port; /* base port to announce on cluster bus. */
int cluster_announce_bus_port; /* bus port to announce on cluster bus. */
+ int cluster_module_flags; /* Set of flags that Redis modules are able
+ to set in order to suppress certain
+ native Redis Cluster features. Check the
+ REDISMODULE_CLUSTER_FLAG_*. */
/* Scripting */
lua_State *lua; /* The Lua interpreter. We use just one for all clients */
client *lua_client; /* The "fake client" to query Redis from Lua */