@@ -97,13 +97,22 @@ def __init__(self, client, **kwargs):
9797 # CMS_INCRBY: spaceHolder,
9898 # CMS_QUERY: spaceHolder,
9999 CMS_MERGE : bool_ok ,
100+ }
101+
102+ RESP2_MODULE_CALLBACKS = {
100103 CMS_INFO : CMSInfo ,
101104 }
105+ RESP3_MODULE_CALLBACKS = {}
102106
103107 self .client = client
104108 self .commandmixin = CMSCommands
105109 self .execute_command = client .execute_command
106110
111+ if self .client .connection_pool .connection_kwargs .get ("protocol" ) in ["3" , 3 ]:
112+ MODULE_CALLBACKS .update (RESP3_MODULE_CALLBACKS )
113+ else :
114+ MODULE_CALLBACKS .update (RESP2_MODULE_CALLBACKS )
115+
107116 for k , v in MODULE_CALLBACKS .items ():
108117 self .client .set_response_callback (k , v )
109118
@@ -114,18 +123,27 @@ def __init__(self, client, **kwargs):
114123 # Set the module commands' callbacks
115124 MODULE_CALLBACKS = {
116125 TOPK_RESERVE : bool_ok ,
117- TOPK_ADD : parse_to_list ,
118- TOPK_INCRBY : parse_to_list ,
119126 # TOPK_QUERY: spaceHolder,
120127 # TOPK_COUNT: spaceHolder,
128+ }
129+
130+ RESP2_MODULE_CALLBACKS = {
131+ TOPK_ADD : parse_to_list ,
132+ TOPK_INCRBY : parse_to_list ,
121133 TOPK_LIST : parse_to_list ,
122134 TOPK_INFO : TopKInfo ,
123135 }
136+ RESP3_MODULE_CALLBACKS = {}
124137
125138 self .client = client
126139 self .commandmixin = TOPKCommands
127140 self .execute_command = client .execute_command
128141
142+ if self .client .connection_pool .connection_kwargs .get ("protocol" ) in ["3" , 3 ]:
143+ MODULE_CALLBACKS .update (RESP3_MODULE_CALLBACKS )
144+ else :
145+ MODULE_CALLBACKS .update (RESP2_MODULE_CALLBACKS )
146+
129147 for k , v in MODULE_CALLBACKS .items ():
130148 self .client .set_response_callback (k , v )
131149
@@ -145,13 +163,22 @@ def __init__(self, client, **kwargs):
145163 # CF_COUNT: spaceHolder,
146164 # CF_SCANDUMP: spaceHolder,
147165 # CF_LOADCHUNK: spaceHolder,
166+ }
167+
168+ RESP2_MODULE_CALLBACKS = {
148169 CF_INFO : CFInfo ,
149170 }
171+ RESP3_MODULE_CALLBACKS = {}
150172
151173 self .client = client
152174 self .commandmixin = CFCommands
153175 self .execute_command = client .execute_command
154176
177+ if self .client .connection_pool .connection_kwargs .get ("protocol" ) in ["3" , 3 ]:
178+ MODULE_CALLBACKS .update (RESP3_MODULE_CALLBACKS )
179+ else :
180+ MODULE_CALLBACKS .update (RESP2_MODULE_CALLBACKS )
181+
155182 for k , v in MODULE_CALLBACKS .items ():
156183 self .client .set_response_callback (k , v )
157184
@@ -165,22 +192,29 @@ def __init__(self, client, **kwargs):
165192 # TDIGEST_RESET: bool_ok,
166193 # TDIGEST_ADD: spaceHolder,
167194 # TDIGEST_MERGE: spaceHolder,
195+ }
196+
197+ RESP2_MODULE_CALLBACKS = {
198+ TDIGEST_BYRANK : parse_to_list ,
199+ TDIGEST_BYREVRANK : parse_to_list ,
168200 TDIGEST_CDF : parse_to_list ,
169201 TDIGEST_QUANTILE : parse_to_list ,
170202 TDIGEST_MIN : float ,
171203 TDIGEST_MAX : float ,
172204 TDIGEST_TRIMMED_MEAN : float ,
173205 TDIGEST_INFO : TDigestInfo ,
174- TDIGEST_RANK : parse_to_list ,
175- TDIGEST_REVRANK : parse_to_list ,
176- TDIGEST_BYRANK : parse_to_list ,
177- TDIGEST_BYREVRANK : parse_to_list ,
178206 }
207+ RESP3_MODULE_CALLBACKS = {}
179208
180209 self .client = client
181210 self .commandmixin = TDigestCommands
182211 self .execute_command = client .execute_command
183212
213+ if self .client .connection_pool .connection_kwargs .get ("protocol" ) in ["3" , 3 ]:
214+ MODULE_CALLBACKS .update (RESP3_MODULE_CALLBACKS )
215+ else :
216+ MODULE_CALLBACKS .update (RESP2_MODULE_CALLBACKS )
217+
184218 for k , v in MODULE_CALLBACKS .items ():
185219 self .client .set_response_callback (k , v )
186220
@@ -199,12 +233,21 @@ def __init__(self, client, **kwargs):
199233 # BF_SCANDUMP: spaceHolder,
200234 # BF_LOADCHUNK: spaceHolder,
201235 # BF_CARD: spaceHolder,
236+ }
237+
238+ RESP2_MODULE_CALLBACKS = {
202239 BF_INFO : BFInfo ,
203240 }
241+ RESP3_MODULE_CALLBACKS = {}
204242
205243 self .client = client
206244 self .commandmixin = BFCommands
207245 self .execute_command = client .execute_command
208246
247+ if self .client .connection_pool .connection_kwargs .get ("protocol" ) in ["3" , 3 ]:
248+ MODULE_CALLBACKS .update (RESP3_MODULE_CALLBACKS )
249+ else :
250+ MODULE_CALLBACKS .update (RESP2_MODULE_CALLBACKS )
251+
209252 for k , v in MODULE_CALLBACKS .items ():
210253 self .client .set_response_callback (k , v )
0 commit comments