redis-cluster-client 0.3.13 → 0.3.15

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: a99b3cb82de7749e845190ab4db8570408706ec659743925d9ebd648ac4af815
4
- data.tar.gz: 6b12b2ac3844eaf2f9bce51767a84931d3a9b9abf2b235012ce0b4db483797fe
3
+ metadata.gz: c0492c31a84cc5a5982973891f9c305d67d6121f03fb12fef76b7045a8960421
4
+ data.tar.gz: e2531e6b21591974103c794cea27fa7383fb3c7aef27ab08850d7468bc6555c0
5
5
  SHA512:
6
- metadata.gz: d33869ee9bbb6ea3f71a90dd18752b5d5f9bd93652b61195f08f88eadfefe363380e1645303dfe1fad4a98992f14fea8e4277e3adadfc9d84f318712a1d59876
7
- data.tar.gz: 7c1cc1f67ba80f363be78bcaf9b25f1c373356d5c03f9f15c2828f74a6500706311c633c2faec1194ab1d2d2bb1905c355f666820070a7d624730cf86698e576
6
+ metadata.gz: 472a05c3122f7847df1fa316ac1e20722abb5c34a299daf2dee71cc71a3cf74437100f97c9ed2105a105b517bdf01066a8702296182126a232d5b7cc463caac0
7
+ data.tar.gz: 9c5bfa33629d5ec005e20c8672748967796a150a190a7aa9de46f11225731b0cec6ce02b6e00b7b94ba1703d5bd103e584d538ccf5219a10c713fbc206f07598
@@ -48,7 +48,7 @@ class RedisClient
48
48
  min = DUMMY_LATENCY_NSEC
49
49
  MEASURE_ATTEMPT_COUNT.times do
50
50
  starting = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond)
51
- client.send(:call_once, 'PING')
51
+ client.call_once('PING')
52
52
  duration = Process.clock_gettime(Process::CLOCK_MONOTONIC, :microsecond) - starting
53
53
  min = duration if duration < min
54
54
  end
@@ -285,7 +285,7 @@ class RedisClient
285
285
 
286
286
  def call_multiple_nodes(clients, method, command, args, &block)
287
287
  results, errors = try_map(clients) do |_, client|
288
- client.send(method, *args, command, &block)
288
+ client.public_send(method, *args, command, &block)
289
289
  end
290
290
 
291
291
  [results&.values, errors]
@@ -81,6 +81,14 @@ class RedisClient
81
81
  end
82
82
  end
83
83
 
84
+ ::RedisClient.class_eval do
85
+ attr_reader :middlewares
86
+
87
+ def ensure_connected_cluster_scoped(retryable: true, &block)
88
+ ensure_connected(retryable: retryable, &block)
89
+ end
90
+ end
91
+
84
92
  ReplySizeError = Class.new(::RedisClient::Error)
85
93
 
86
94
  class RedirectionNeeded < ::RedisClient::Error
@@ -198,9 +206,9 @@ class RedisClient
198
206
  end
199
207
 
200
208
  def send_pipeline(client, pipeline)
201
- results = client.send(:ensure_connected, retryable: pipeline._retryable?) do |connection|
209
+ results = client.ensure_connected_cluster_scoped(retryable: pipeline._retryable?) do |connection|
202
210
  commands = pipeline._commands
203
- client.instance_variable_get(:@middlewares).call_pipelined(commands, client.config) do
211
+ client.middlewares.call_pipelined(commands, client.config) do
204
212
  connection.call_pipelined_aware_of_redirection(commands, pipeline._timeouts)
205
213
  end
206
214
  end
@@ -68,9 +68,9 @@ class RedisClient
68
68
  def try_send(node, method, command, args, retry_count: 3, &block) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
69
69
  if args.empty?
70
70
  # prevent memory allocation for variable-length args
71
- node.send(method, command, &block)
71
+ node.public_send(method, command, &block)
72
72
  else
73
- node.send(method, *args, command, &block)
73
+ node.public_send(method, *args, command, &block)
74
74
  end
75
75
  rescue ::RedisClient::CommandError => e
76
76
  raise if retry_count <= 0
@@ -101,7 +101,7 @@ class RedisClient
101
101
  end
102
102
 
103
103
  def try_delegate(node, method, *args, retry_count: 3, **kwargs, &block) # rubocop:disable Metrics/AbcSize
104
- node.send(method, *args, **kwargs, &block)
104
+ node.public_send(method, *args, **kwargs, &block)
105
105
  rescue ::RedisClient::CommandError => e
106
106
  raise if retry_count <= 0
107
107
 
@@ -214,7 +214,7 @@ class RedisClient
214
214
  case ::RedisClient::Cluster::NormalizedCmdName.instance.get_by_subcommand(command)
215
215
  when 'resetstat', 'rewrite', 'set'
216
216
  @node.call_all(method, command, args, &block).first
217
- else assign_node(command).send(method, *args, command, &block)
217
+ else assign_node(command).public_send(method, *args, command, &block)
218
218
  end
219
219
  end
220
220
 
@@ -222,7 +222,7 @@ class RedisClient
222
222
  case ::RedisClient::Cluster::NormalizedCmdName.instance.get_by_subcommand(command)
223
223
  when 'stats' then @node.call_all(method, command, args, &block)
224
224
  when 'purge' then @node.call_all(method, command, args, &block).first
225
- else assign_node(command).send(method, *args, command, &block)
225
+ else assign_node(command).public_send(method, *args, command, &block)
226
226
  end
227
227
  end
228
228
 
@@ -231,7 +231,7 @@ class RedisClient
231
231
  when 'list' then @node.call_all(method, command, args, &block).flatten
232
232
  when 'pause', 'reply', 'setname'
233
233
  @node.call_all(method, command, args, &block).first
234
- else assign_node(command).send(method, *args, command, &block)
234
+ else assign_node(command).public_send(method, *args, command, &block)
235
235
  end
236
236
  end
237
237
 
@@ -244,8 +244,8 @@ class RedisClient
244
244
  when 'getkeysinslot'
245
245
  raise ArgumentError, command.join(' ') if command.size != 4
246
246
 
247
- find_node(@node.find_node_key_of_replica(command[2])).send(method, *args, command, &block)
248
- else assign_node(command).send(method, *args, command, &block)
247
+ find_node(@node.find_node_key_of_replica(command[2])).public_send(method, *args, command, &block)
248
+ else assign_node(command).public_send(method, *args, command, &block)
249
249
  end
250
250
  end
251
251
 
@@ -255,7 +255,9 @@ class RedisClient
255
255
  @node.call_all(method, command, args, &block).first
256
256
  when 'flush', 'load'
257
257
  @node.call_primaries(method, command, args, &block).first
258
- else assign_node(command).send(method, *args, command, &block)
258
+ when 'exists'
259
+ @node.call_all(method, command, args, &block).transpose.map { |arr| arr.any?(&:zero?) ? 0 : 1 }
260
+ else assign_node(command).public_send(method, *args, command, &block)
259
261
  end
260
262
  end
261
263
 
@@ -266,7 +268,7 @@ class RedisClient
266
268
  @node.call_all(method, command, args, &block).reject(&:empty?).map { |e| Hash[*e] }
267
269
  .reduce({}) { |a, e| a.merge(e) { |_, v1, v2| v1 + v2 } }
268
270
  when 'numpat' then @node.call_all(method, command, args, &block).select { |e| e.is_a?(Integer) }.sum
269
- else assign_node(command).send(method, *args, command, &block)
271
+ else assign_node(command).public_send(method, *args, command, &block)
270
272
  end
271
273
  end
272
274
 
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.13
4
+ version: 0.3.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-12 00:00:00.000000000 Z
11
+ date: 2022-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.10'
19
+ version: '0.11'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: '0.10'
26
+ version: '0.11'
27
27
  description:
28
28
  email:
29
29
  - proxy0721@gmail.com
@@ -69,7 +69,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
69
69
  - !ruby/object:Gem::Version
70
70
  version: '0'
71
71
  requirements: []
72
- rubygems_version: 3.3.22
72
+ rubygems_version: 3.3.23
73
73
  signing_key:
74
74
  specification_version: 4
75
75
  summary: A Redis cluster client for Ruby