@@ -20,11 +20,13 @@ def initialize(config, pool: nil, **kwargs)
20
20
@client_kwargs = kwargs
21
21
@node = fetch_cluster_info ( @config , pool : @pool , **@client_kwargs )
22
22
@command = ::RedisClient ::Cluster ::Command . load ( @node )
23
+ @command_builder = @config . command_builder
23
24
@mutex = Mutex . new
24
25
end
25
26
26
27
def send_command ( method , *args , **kwargs , &block ) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/MethodLength, Metrics/PerceivedComplexity
27
28
command = method == :blocking_call && args . size > 1 ? args [ 1 ..] : args
29
+ command = @command_builder . generate! ( command , kwargs )
28
30
29
31
cmd = command . first . to_s . downcase
30
32
case cmd
@@ -95,6 +97,8 @@ def try_send(node, method, *args, retry_count: 3, **kwargs, &block) # rubocop:di
95
97
end
96
98
97
99
def scan ( *command , **kwargs ) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
100
+ command = @command_builder . generate! ( command , kwargs )
101
+
98
102
command [ 1 ] = ZERO_CURSOR_FOR_SCAN if command . size == 1
99
103
input_cursor = Integer ( command [ 1 ] )
100
104
@@ -116,12 +120,14 @@ def scan(*command, **kwargs) # rubocop:disable Metrics/MethodLength, Metrics/Abc
116
120
[ ( ( result_cursor << 8 ) + client_index ) . to_s , result_keys ]
117
121
end
118
122
119
- def assign_node ( *command )
120
- node_key = find_node_key ( *command )
123
+ def assign_node ( *command , ** kwargs )
124
+ node_key = find_node_key ( *command , ** kwargs )
121
125
find_node ( node_key )
122
126
end
123
127
124
- def find_node_key ( *command , primary_only : false )
128
+ def find_node_key ( *command , primary_only : false , **kwargs )
129
+ command = @command_builder . generate! ( command , kwargs )
130
+
125
131
key = @command . extract_first_key ( command )
126
132
slot = key . empty? ? nil : ::RedisClient ::Cluster ::KeySlotConverter . convert ( key )
127
133
@@ -163,6 +169,7 @@ def send_wait_command(method, *args, retry_count: 3, **kwargs, &block)
163
169
164
170
def send_config_command ( method , *args , **kwargs , &block )
165
171
command = method == :blocking_call && args . size > 1 ? args [ 1 ..] : args
172
+ command = @command_builder . generate! ( command , kwargs )
166
173
167
174
case command [ 1 ] . to_s . downcase
168
175
when 'resetstat' , 'rewrite' , 'set'
@@ -173,6 +180,7 @@ def send_config_command(method, *args, **kwargs, &block)
173
180
174
181
def send_memory_command ( method , *args , **kwargs , &block )
175
182
command = method == :blocking_call && args . size > 1 ? args [ 1 ..] : args
183
+ command = @command_builder . generate! ( command , kwargs )
176
184
177
185
case command [ 1 ] . to_s . downcase
178
186
when 'stats' then @node . call_all ( method , *args , **kwargs , &block )
@@ -183,6 +191,7 @@ def send_memory_command(method, *args, **kwargs, &block)
183
191
184
192
def send_client_command ( method , *args , **kwargs , &block )
185
193
command = method == :blocking_call && args . size > 1 ? args [ 1 ..] : args
194
+ command = @command_builder . generate! ( command , kwargs )
186
195
187
196
case command [ 1 ] . to_s . downcase
188
197
when 'list' then @node . call_all ( method , *args , **kwargs , &block ) . flatten
@@ -194,6 +203,7 @@ def send_client_command(method, *args, **kwargs, &block)
194
203
195
204
def send_cluster_command ( method , *args , **kwargs , &block ) # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
196
205
command = method == :blocking_call && args . size > 1 ? args [ 1 ..] : args
206
+ command = @command_builder . generate! ( command , kwargs )
197
207
subcommand = command [ 1 ] . to_s . downcase
198
208
199
209
case subcommand
@@ -211,6 +221,7 @@ def send_cluster_command(method, *args, **kwargs, &block) # rubocop:disable Metr
211
221
212
222
def send_script_command ( method , *args , **kwargs , &block )
213
223
command = method == :blocking_call && args . size > 1 ? args [ 1 ..] : args
224
+ command = @command_builder . generate! ( command , kwargs )
214
225
215
226
case command [ 1 ] . to_s . downcase
216
227
when 'debug' , 'kill'
@@ -223,6 +234,7 @@ def send_script_command(method, *args, **kwargs, &block)
223
234
224
235
def send_pubsub_command ( method , *args , **kwargs , &block ) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
225
236
command = method == :blocking_call && args . size > 1 ? args [ 1 ..] : args
237
+ command = @command_builder . generate! ( command , kwargs )
226
238
227
239
case command [ 1 ] . to_s . downcase
228
240
when 'channels' then @node . call_all ( method , *args , **kwargs , &block ) . flatten . uniq . sort_by ( &:to_s )
0 commit comments