redis-cluster-client 0.17.2 → 0.17.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/redis_client/cluster/router.rb +41 -17
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: d99c93a4972ec806a5152ec5f550c5bb6c6e40a42932359ca0093e03cd6f6404
|
|
4
|
+
data.tar.gz: 72b055252677077791916fa85bd3c12bc566c0acba36afcd218f8e4691efeaee
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 1e9d299dff3df85e3181d8a949e348985307d09d4ec2fa4d3de2795e11425ac2b988df0fecd1681af70974d6c315df3541d97aed53e449cc9839df252ce0a85d
|
|
7
|
+
data.tar.gz: 1f565bcc5c5e299b721309a1ba9273bc56016f4a62cf0a153cc4ecec4b7e355c4fc54488329537e1fe8733d09969ad34866d5998cfa6043667051dafc8d1884b
|
|
@@ -39,16 +39,9 @@ class RedisClient
|
|
|
39
39
|
|
|
40
40
|
def send_command(method, command, *args, &block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
|
|
41
41
|
action = @dedicated_actions[command.first]
|
|
42
|
-
if action.nil?
|
|
43
|
-
cmd_spec = @command.get_spec(command)
|
|
44
|
-
action = find_policy_action(cmd_spec)
|
|
45
|
-
return assign_node_and_send_command(method, command, args, cmd_spec: cmd_spec, &block) if action.nil?
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
return send(action.method_name, method, command, args, &block) if action.reply_transformer.nil?
|
|
42
|
+
return send_command_by_spec(method, command, args, &block) if action.nil?
|
|
49
43
|
|
|
50
|
-
|
|
51
|
-
action.reply_transformer.call(reply).then(&TSF.call(block))
|
|
44
|
+
send_command_by_action(action, method, command, args, &block)
|
|
52
45
|
rescue ::RedisClient::CircuitBreaker::OpenCircuitError
|
|
53
46
|
raise
|
|
54
47
|
rescue ::RedisClient::Cluster::Node::ReloadNeeded
|
|
@@ -258,6 +251,22 @@ class RedisClient
|
|
|
258
251
|
|
|
259
252
|
private
|
|
260
253
|
|
|
254
|
+
# Follows the command tips which the server reports, or the routing by the key.
|
|
255
|
+
def send_command_by_spec(method, command, args, &block)
|
|
256
|
+
cmd_spec = @command.get_spec(command)
|
|
257
|
+
action = find_policy_action(cmd_spec)
|
|
258
|
+
return assign_node_and_send_command(method, command, args, cmd_spec: cmd_spec, &block) if action.nil?
|
|
259
|
+
|
|
260
|
+
send_command_by_action(action, method, command, args, &block)
|
|
261
|
+
end
|
|
262
|
+
|
|
263
|
+
def send_command_by_action(action, method, command, args, &block)
|
|
264
|
+
return send(action.method_name, method, command, args, &block) if action.reply_transformer.nil?
|
|
265
|
+
|
|
266
|
+
reply = send(action.method_name, method, command, args)
|
|
267
|
+
action.reply_transformer.call(reply).then(&TSF.call(block))
|
|
268
|
+
end
|
|
269
|
+
|
|
261
270
|
def find_policy_action(cmd_spec)
|
|
262
271
|
return if cmd_spec.nil?
|
|
263
272
|
|
|
@@ -331,7 +340,8 @@ class RedisClient
|
|
|
331
340
|
if command[1].casecmp('scan').zero?
|
|
332
341
|
scan(command, seed: 1, cursor_index: 2).then(&TSF.call(block))
|
|
333
342
|
else
|
|
334
|
-
|
|
343
|
+
# The other subcommands keep the default routing with the redirection handling.
|
|
344
|
+
send_command_by_spec(method, command, args, &block)
|
|
335
345
|
end
|
|
336
346
|
end
|
|
337
347
|
|
|
@@ -341,7 +351,8 @@ class RedisClient
|
|
|
341
351
|
elsif command[1].casecmp('purge').zero?
|
|
342
352
|
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
343
353
|
else
|
|
344
|
-
|
|
354
|
+
# The other subcommands keep the default routing with the redirection handling.
|
|
355
|
+
send_command_by_spec(method, command, args, &block)
|
|
345
356
|
end
|
|
346
357
|
end
|
|
347
358
|
|
|
@@ -350,12 +361,15 @@ class RedisClient
|
|
|
350
361
|
@node.call_all(method, command, args, &block).flatten
|
|
351
362
|
elsif command[1].casecmp('pause').zero?
|
|
352
363
|
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
364
|
+
elsif command[1].casecmp('unpause').zero?
|
|
365
|
+
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
353
366
|
elsif command[1].casecmp('reply').zero?
|
|
354
367
|
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
355
368
|
elsif command[1].casecmp('setname').zero?
|
|
356
369
|
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
357
370
|
else
|
|
358
|
-
|
|
371
|
+
# The other subcommands keep the default routing with the command tips.
|
|
372
|
+
send_command_by_spec(method, command, args, &block)
|
|
359
373
|
end
|
|
360
374
|
end
|
|
361
375
|
|
|
@@ -366,8 +380,15 @@ class RedisClient
|
|
|
366
380
|
command[1].casecmp('slots').zero? ||
|
|
367
381
|
command[1].casecmp('shards').zero? ||
|
|
368
382
|
command[1].casecmp('count-failure-reports').zero? ||
|
|
369
|
-
command[1].casecmp('slaves').zero?
|
|
383
|
+
command[1].casecmp('slaves').zero? ||
|
|
384
|
+
command[1].casecmp('replicas').zero? ||
|
|
385
|
+
command[1].casecmp('myid').zero? ||
|
|
386
|
+
command[1].casecmp('myshardid').zero? ||
|
|
387
|
+
command[1].casecmp('links').zero?
|
|
370
388
|
assign_node(command).public_send(method, *args, command, &block)
|
|
389
|
+
elsif command[1].casecmp('slot-stats').zero?
|
|
390
|
+
# Each primary replies with the statistics of its own slots only.
|
|
391
|
+
@node.call_primaries(method, command, args).flatten(1).then(&TSF.call(block))
|
|
371
392
|
elsif command[1].casecmp('saveconfig').zero?
|
|
372
393
|
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
373
394
|
elsif command[1].casecmp('countkeysinslot').zero? || command[1].casecmp('getkeysinslot').zero?
|
|
@@ -384,15 +405,18 @@ class RedisClient
|
|
|
384
405
|
if command[1].casecmp('debug').zero?
|
|
385
406
|
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
386
407
|
elsif command[1].casecmp('kill').zero?
|
|
387
|
-
|
|
408
|
+
# The primaries without any running script reply with the NOTBUSY error.
|
|
409
|
+
@node.call_primaries_leniently(method, command, args).first.then(&TSF.call(block))
|
|
388
410
|
elsif command[1].casecmp('flush').zero?
|
|
389
|
-
|
|
411
|
+
# The redis 7.0 or later doesn't propagate the scripts to the replicas.
|
|
412
|
+
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
390
413
|
elsif command[1].casecmp('load').zero?
|
|
391
|
-
@node.
|
|
414
|
+
@node.call_all(method, command, args).first.then(&TSF.call(block))
|
|
392
415
|
elsif command[1].casecmp('exists').zero?
|
|
393
416
|
@node.call_all(method, command, args).transpose.map { |arr| arr.any?(&:zero?) ? 0 : 1 }.then(&TSF.call(block))
|
|
394
417
|
else
|
|
395
|
-
|
|
418
|
+
# The other subcommands keep the default routing with the redirection handling.
|
|
419
|
+
send_command_by_spec(method, command, args, &block)
|
|
396
420
|
end
|
|
397
421
|
end
|
|
398
422
|
|