redis-cluster-client 0.4.8 → 0.4.9

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: 19e03bc6e2b6ddf57697c9e63dd5ffa729e6621979b3daef02b28062dc328494
4
+ data.tar.gz: f212df153cda0c53710c5f03586c01042d168380982113e4dd354ae859c276b4
5
5
  SHA512:
6
- metadata.gz: 101ec6c98f8f2164b4c8da1a497ca31ca456d7c567ac9c96e8ac3220b37be96160ad558111c19e92d67c1947c29523463011c073016158a2930c7462231f3bc8
7
- data.tar.gz: 72067a86f5fb1839bab4766dad20e5157932238c1a6237c9de805cf7dbd77e784b5b1b47e560f3585550521b36632dd7e9a094ccecad0e4ee893eb27bfc1f342
6
+ metadata.gz: e6034b7693d67eaec5e979fe5cce0c310746262971a77642392930ee1dc2be2cefcad6ac3729cc8d11fb3a2d3ba1077ee2aacfef618fc570c688850056f1c1f6
7
+ data.tar.gz: 5182806018f1452094085cea4f2c1bd70ecbfe71d4d5b178fec7f06712debd4cb843fb794ab1b1d29df61204a14db9a0e92eb133f40ffcb732397dd76c7e199f
@@ -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
@@ -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.9
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