redis-cluster-client 0.4.8 → 0.4.10

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eab80ca6b1a69e3c45bc0dd59f9dd05189559907e0976a534ddc5dc0de26527b
4
- data.tar.gz: 90aa485da1918f0a46f36964ff7ede3c775dcf90ebf0477df0a6d5f2cc3846f7
3
+ metadata.gz: a8db8a7aac1f09df0c2fc3c7da3f0227246671d2fd0a199dabcda22caa0787d3
4
+ data.tar.gz: d0431f663859765f0ff3f537f4f74fcd17a72c561b615616ae5e24543bb3d3df
5
5
  SHA512:
6
- metadata.gz: 101ec6c98f8f2164b4c8da1a497ca31ca456d7c567ac9c96e8ac3220b37be96160ad558111c19e92d67c1947c29523463011c073016158a2930c7462231f3bc8
7
- data.tar.gz: 72067a86f5fb1839bab4766dad20e5157932238c1a6237c9de805cf7dbd77e784b5b1b47e560f3585550521b36632dd7e9a094ccecad0e4ee893eb27bfc1f342
6
+ metadata.gz: bed8b8bc6f6321808fcee27b30c43746eca124abad25bbdb7923bc6b6faf56cb53343008fcf4648d4be56df42d7e8baa1a105206ff6a7370dae9c528bf7213cc
7
+ data.tar.gz: 1ee8f2edc8207011ccdda3a3d863895adc5ae0f3747b4b62374a96cbb19779f00b13fb350aa519a38083708da250f0e3249667c0a8dbaaeaf07781f2dcf0cbdd
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'redis_client'
4
+
3
5
  class RedisClient
4
6
  class Cluster
5
7
  class PubSub
@@ -20,7 +22,7 @@ class RedisClient
20
22
 
21
23
  def take_message(timeout)
22
24
  @worker = subscribe(@client, timeout) if @worker.nil?
23
- return if @worker.join(0.01).nil?
25
+ return if @worker.alive?
24
26
 
25
27
  message = @worker[:reply]
26
28
  @worker = nil
@@ -76,8 +78,26 @@ class RedisClient
76
78
 
77
79
  def _call(command)
78
80
  node_key = @router.find_node_key(command)
79
- @states[node_key] = State.new(@router.find_node(node_key).pubsub) unless @states.key?(node_key)
81
+ add_state(node_key)
82
+ try_call(node_key, command)
83
+ end
84
+
85
+ def try_call(node_key, command, retry_count: 1)
80
86
  @states[node_key].call(command)
87
+ rescue ::RedisClient::CommandError => e
88
+ raise if !e.message.start_with?('MOVED') || retry_count <= 0
89
+
90
+ # for sharded pub/sub
91
+ node_key = e.message.split[2]
92
+ add_state(node_key)
93
+ retry_count -= 1
94
+ retry
95
+ end
96
+
97
+ def add_state(node_key)
98
+ return @states[node_key] if @states.key?(node_key)
99
+
100
+ @states[node_key] = State.new(@router.find_node(node_key).pubsub)
81
101
  end
82
102
 
83
103
  def obtain_current_time
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.8
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-08-10 00:00:00.000000000 Z
11
+ date: 2023-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client