redis-cluster-client 0.17.0 → 0.17.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7df1ba6006c9d3c3e7c242e9406f6443a95aa371c7e77244b73565058f476435
4
- data.tar.gz: 5613bf92dc543482c1bcb2e74d61096092c299ef84877b8c06da1174db82c6d4
3
+ metadata.gz: 359726530c2640f2ceb9c6c06322c4608fec64338c33d3b29f675b1e152c6700
4
+ data.tar.gz: ec32116a8cde689a6ea78cc029159174404288c63b452d797ff3646669b5141e
5
5
  SHA512:
6
- metadata.gz: 58e9ecaa1aecf6bfb298cba78e08d349f742439a2f5a53e19cd55bb49c8a600b4e4f47a54af1798ef0afe51cb56cf5cf292eda3bdf75e522ed180fa065e37954
7
- data.tar.gz: c158336f83f4453e27798a2521c4e282a867db446dfa7e74e988af9e568567235b321b59386bf79ac5d0e32dee0698137755e9c416ceeb3acb150ebfc60d5208
6
+ metadata.gz: f4b810aa80374e5720533c82846ac0485682c6b8bcd5902c6a71a9b4d2c830914a3d97cfb8c378a402b3cd44cd5a96361067d461f177d8672b918a3b6911a38d
7
+ data.tar.gz: 4614bba3d265eeedf3ebe72fa75ab10ca2543a48aa0e622b530fa54ad1701af158a77819e4d0cd6aa7ce1f913df139169497caf084186eb6875a49e312b84d94
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'set'
3
4
  require 'redis_client'
4
5
  require 'redis_client/cluster/errors'
5
6
  require 'redis_client/cluster/noop_command_builder'
@@ -44,6 +45,19 @@ class RedisClient
44
45
  def get_block(inner_index)
45
46
  @blocks.is_a?(Array) ? @blocks[inner_index] : nil
46
47
  end
48
+
49
+ def coerce_except!(replies, indices)
50
+ return replies unless @blocks.is_a?(Array)
51
+
52
+ skipped = Set.new(indices)
53
+ @blocks.each_with_index do |block, index|
54
+ next if block.nil? || skipped.include?(index)
55
+
56
+ replies[index] = block.call(replies[index])
57
+ end
58
+
59
+ replies
60
+ end
47
61
  end
48
62
 
49
63
  ::RedisClient::ConnectionMixin.module_eval do
@@ -209,6 +223,7 @@ class RedisClient
209
223
 
210
224
  all_replies ||= Array.new(@size)
211
225
  pipeline = @pipelines[node_key]
226
+ pipeline.coerce_except!(v.replies, v.indices)
212
227
  v.indices.each { |i| v.replies[i] = handle_redirection(v.replies[i], pipeline, i) }
213
228
  pipeline.outer_indices.each_with_index { |outer, inner| all_replies[outer] = v.replies[inner] }
214
229
  end
@@ -217,7 +232,9 @@ class RedisClient
217
232
  raise v.first_exception if v.first_exception
218
233
 
219
234
  all_replies ||= Array.new(@size)
220
- @pipelines[node_key].outer_indices.each_with_index { |outer, inner| all_replies[outer] = v.replies[inner] }
235
+ pipeline = @pipelines[node_key]
236
+ pipeline._coerce!(v.replies)
237
+ pipeline.outer_indices.each_with_index { |outer, inner| all_replies[outer] = v.replies[inner] }
221
238
  end
222
239
 
223
240
  all_replies
@@ -33,6 +33,7 @@ class RedisClient
33
33
  'keys' => RoutingAction.new(method_name: :send_command_to_replicas, reply_transformer: FLATTEN_STRINGS),
34
34
  'dbsize' => RoutingAction.new(method_name: :send_command_to_replicas, reply_transformer: SUM_NUM),
35
35
  'scan' => RoutingAction.new(method_name: :send_scan_command),
36
+ 'bless' => RoutingAction.new(method_name: :send_bless_command),
36
37
  'lastsave' => RoutingAction.new(method_name: :send_command_to_all_nodes, reply_transformer: SORT_NUMBERS),
37
38
  'role' => RoutingAction.new(method_name: :send_command_to_all_nodes),
38
39
  'config' => RoutingAction.new(method_name: :send_config_command),
@@ -133,9 +133,9 @@ class RedisClient
133
133
  retry
134
134
  end
135
135
 
136
- def scan(command, seed: nil) # rubocop:disable Metrics/AbcSize
137
- command[1] = ZERO_CURSOR_FOR_SCAN if command.size == 1
138
- input_cursor = Integer(command[1])
136
+ def scan(command, seed: nil, cursor_index: 1) # rubocop:disable Metrics/AbcSize
137
+ command[cursor_index] = ZERO_CURSOR_FOR_SCAN if command.size == cursor_index
138
+ input_cursor = Integer(command[cursor_index])
139
139
 
140
140
  client_index = input_cursor % 256
141
141
  raw_cursor = input_cursor >> 8
@@ -145,7 +145,7 @@ class RedisClient
145
145
  client = clients[client_index]
146
146
  return [ZERO_CURSOR_FOR_SCAN, []] unless client
147
147
 
148
- command[1] = raw_cursor.to_s
148
+ command[cursor_index] = raw_cursor.to_s
149
149
 
150
150
  result_cursor, result_keys = client.call_v(command)
151
151
  result_cursor = Integer(result_cursor)
@@ -327,6 +327,14 @@ class RedisClient
327
327
  end
328
328
  end
329
329
 
330
+ def send_bless_command(method, command, args, &block)
331
+ if command[1].casecmp('scan').zero?
332
+ scan(command, seed: 1, cursor_index: 2).then(&TSF.call(block))
333
+ else
334
+ assign_node(command).public_send(method, *args, command, &block)
335
+ end
336
+ end
337
+
330
338
  def send_memory_command(method, command, args, &block)
331
339
  if command[1].casecmp('stats').zero?
332
340
  @node.call_all(method, command, args, &block)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.17.0
4
+ version: 0.17.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 4.0.16
78
+ rubygems_version: 4.0.20
79
79
  specification_version: 4
80
80
  summary: Redis cluster-aware client for Ruby
81
81
  test_files: []