summaryrefslogtreecommitdiff
path: root/redis/cluster.py
diff options
context:
space:
mode:
authordvora-h <67596500+dvora-h@users.noreply.github.com>2022-03-14 15:03:58 +0200
committerGitHub <noreply@github.com>2022-03-14 15:03:58 +0200
commitb4421101aeb19aebcfbcb66ac03314e4c535f063 (patch)
tree6166b5ae2951d2bb09c96ac421dc240520d8523e /redis/cluster.py
parentfdf4f1adb9e2636a04343a3bfade2abac6877197 (diff)
downloadredis-py-b4421101aeb19aebcfbcb66ac03314e4c535f063.tar.gz
Add support for SEARCH commands in cluster (#2042)
* Add support for SEARCH commands in cluster * delete json tests mark & list search commands * linters
Diffstat (limited to 'redis/cluster.py')
-rw-r--r--redis/cluster.py47
1 files changed, 41 insertions, 6 deletions
diff --git a/redis/cluster.py b/redis/cluster.py
index 87643a7..09c9ab7 100644
--- a/redis/cluster.py
+++ b/redis/cluster.py
@@ -320,6 +320,42 @@ class RedisCluster(RedisClusterCommands):
),
)
+ SEARCH_COMMANDS = (
+ [
+ "FT.CREATE",
+ "FT.SEARCH",
+ "FT.AGGREGATE",
+ "FT.EXPLAIN",
+ "FT.EXPLAINCLI",
+ "FT,PROFILE",
+ "FT.ALTER",
+ "FT.DROPINDEX",
+ "FT.ALIASADD",
+ "FT.ALIASUPDATE",
+ "FT.ALIASDEL",
+ "FT.TAGVALS",
+ "FT.SUGADD",
+ "FT.SUGGET",
+ "FT.SUGDEL",
+ "FT.SUGLEN",
+ "FT.SYNUPDATE",
+ "FT.SYNDUMP",
+ "FT.SPELLCHECK",
+ "FT.DICTADD",
+ "FT.DICTDEL",
+ "FT.DICTDUMP",
+ "FT.INFO",
+ "FT._LIST",
+ "FT.CONFIG",
+ "FT.ADD",
+ "FT.DEL",
+ "FT.DROP",
+ "FT.GET",
+ "FT.MGET",
+ "FT.SYNADD",
+ ],
+ )
+
CLUSTER_COMMANDS_RESPONSE_CALLBACKS = {
"CLUSTER ADDSLOTS": bool,
"CLUSTER ADDSLOTSRANGE": bool,
@@ -854,6 +890,8 @@ class RedisCluster(RedisClusterCommands):
elif command_flag == self.__class__.DEFAULT_NODE:
# return the cluster's default node
return [self.nodes_manager.default_node]
+ elif command in self.__class__.SEARCH_COMMANDS[0]:
+ return [self.nodes_manager.default_node]
else:
# get the node that holds the key's slot
slot = self.determine_slot(*args)
@@ -1956,17 +1994,14 @@ class ClusterPipeline(RedisCluster):
# refer to our internal node -> slot table that
# tells us where a given
# command should route to.
- slot = self.determine_slot(*c.args)
- node = self.nodes_manager.get_node_from_slot(
- slot, self.read_from_replicas and c.args[0] in READ_COMMANDS
- )
+ node = self._determine_nodes(*c.args)
# now that we know the name of the node
# ( it's just a string in the form of host:port )
# we can build a list of commands for each node.
- node_name = node.name
+ node_name = node[0].name
if node_name not in nodes:
- redis_node = self.get_redis_connection(node)
+ redis_node = self.get_redis_connection(node[0])
connection = get_connection(redis_node, c.args)
nodes[node_name] = NodeCommands(
redis_node.parse_response, redis_node.connection_pool, connection