8
8
from collections import OrderedDict
9
9
10
10
from redis .client import CaseInsensitiveDict , PubSub , Redis
11
- from redis .commands import ClusterCommands , CommandsParser
11
+ from redis .commands import CommandsParser , RedisClusterCommands
12
12
from redis .connection import ConnectionPool , DefaultParser , Encoder , parse_url
13
13
from redis .crc import REDIS_CLUSTER_HASH_SLOTS , key_slot
14
14
from redis .exceptions import (
@@ -94,6 +94,7 @@ def fix_server(*args):
94
94
"charset" ,
95
95
"connection_class" ,
96
96
"connection_pool" ,
97
+ "client_name" ,
97
98
"db" ,
98
99
"decode_responses" ,
99
100
"encoding" ,
@@ -198,7 +199,7 @@ class ClusterParser(DefaultParser):
198
199
)
199
200
200
201
201
- class RedisCluster (ClusterCommands ):
202
+ class RedisCluster (RedisClusterCommands ):
202
203
RedisClusterRequestTTL = 16
203
204
204
205
PRIMARIES = "primaries"
@@ -212,6 +213,18 @@ class RedisCluster(ClusterCommands):
212
213
COMMAND_FLAGS = dict_merge (
213
214
list_keys_to_dict (
214
215
[
216
+ "ACL CAT" ,
217
+ "ACL DELUSER" ,
218
+ "ACL GENPASS" ,
219
+ "ACL GETUSER" ,
220
+ "ACL HELP" ,
221
+ "ACL LIST" ,
222
+ "ACL LOG" ,
223
+ "ACL LOAD" ,
224
+ "ACL SAVE" ,
225
+ "ACL SETUSER" ,
226
+ "ACL USERS" ,
227
+ "ACL WHOAMI" ,
215
228
"CLIENT LIST" ,
216
229
"CLIENT SETNAME" ,
217
230
"CLIENT GETNAME" ,
@@ -770,6 +783,18 @@ def determine_slot(self, *args):
770
783
def reinitialize_caches (self ):
771
784
self .nodes_manager .initialize ()
772
785
786
+ def get_encoder (self ):
787
+ """
788
+ Get the connections' encoder
789
+ """
790
+ return self .encoder
791
+
792
+ def get_connection_kwargs (self ):
793
+ """
794
+ Get the connections' key-word arguments
795
+ """
796
+ return self .nodes_manager .connection_kwargs
797
+
773
798
def _is_nodes_flag (self , target_nodes ):
774
799
return isinstance (target_nodes , str ) and target_nodes in self .node_flags
775
800
@@ -1383,7 +1408,8 @@ def initialize(self):
1383
1408
# isn't a full coverage
1384
1409
raise RedisClusterException (
1385
1410
f"All slots are not covered after query all startup_nodes. "
1386
- f"{ len (self .slots_cache )} of { REDIS_CLUSTER_HASH_SLOTS } covered..."
1411
+ f"{ len (self .slots_cache )} of { REDIS_CLUSTER_HASH_SLOTS } "
1412
+ f"covered..."
1387
1413
)
1388
1414
elif not fully_covered and not self ._require_full_coverage :
1389
1415
# The user set require_full_coverage to False.
@@ -1402,7 +1428,8 @@ def initialize(self):
1402
1428
"cluster-require-full-coverage configuration to no on "
1403
1429
"all of the cluster nodes if you wish the cluster to "
1404
1430
"be able to serve without being fully covered."
1405
- f"{ len (self .slots_cache )} of { REDIS_CLUSTER_HASH_SLOTS } covered..."
1431
+ f"{ len (self .slots_cache )} of { REDIS_CLUSTER_HASH_SLOTS } "
1432
+ f"covered..."
1406
1433
)
1407
1434
1408
1435
# Set the tmp variables to the real variables
@@ -1950,8 +1977,8 @@ def block_pipeline_command(func):
1950
1977
1951
1978
def inner (* args , ** kwargs ):
1952
1979
raise RedisClusterException (
1953
- f"ERROR: Calling pipelined function { func .__name__ } is blocked when "
1954
- f"running redis in cluster mode..."
1980
+ f"ERROR: Calling pipelined function { func .__name__ } is blocked "
1981
+ f"when running redis in cluster mode..."
1955
1982
)
1956
1983
1957
1984
return inner
0 commit comments