Skip to content

Commit 9da80c6

Browse files
authored
fix: a bug for client list command (#197)
1 parent 699dd80 commit 9da80c6

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

lib/redis_client/cluster/router.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Cluster
1414
class Router
1515
ZERO_CURSOR_FOR_SCAN = '0'
1616
METHODS_FOR_BLOCKING_CMD = %i[blocking_call_v blocking_call].freeze
17-
TSF = ->(b, s) { b.nil? ? s : b.call(s) }.curry
17+
TSF = ->(f, x) { f.nil? ? x : f.call(x) }.curry
1818

1919
attr_reader :node
2020

@@ -240,7 +240,7 @@ def send_memory_command(method, command, args, &block)
240240

241241
def send_client_command(method, command, args, &block)
242242
case ::RedisClient::Cluster::NormalizedCmdName.instance.get_by_subcommand(command)
243-
when 'list' then @node.call_all(method, command, args).flatten.then(&TSF.call(block))
243+
when 'list' then @node.call_all(method, command, args, &block).flatten
244244
when 'pause', 'reply', 'setname'
245245
@node.call_all(method, command, args).first.then(&TSF.call(block))
246246
else assign_node(command).public_send(method, *args, command, &block)

test/redis_client/test_cluster.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,11 @@ def test_dedicated_commands # rubocop:disable Metrics/CyclomaticComplexity, Metr
241241
{ command: %w[ROLE], is_a: Array },
242242
{ command: %w[CONFIG RESETSTAT], want: 'OK' },
243243
{ command: %w[CONFIG GET maxmemory], is_a: TEST_REDIS_MAJOR_VERSION < 6 ? Array : Hash },
244-
{ command: %w[CLIENT LIST], is_a: Array },
244+
{
245+
command: %w[CLIENT LIST],
246+
blk: ->(r) { r.lines("\n", chomp: true).map(&:split).map { |e| Hash[e.map { |x| x.split('=') }] } },
247+
is_a: Array
248+
},
245249
{ command: %w[CLIENT PAUSE 100], want: 'OK' },
246250
{ command: %w[CLIENT INFO], is_a: String, supported_redis_version: 6 },
247251
{ command: %w[CLUSTER SET-CONFIG-EPOCH 0], error: ::RedisClient::Cluster::OrchestrationCommandNotSupported },

0 commit comments

Comments
 (0)