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 +4 -4
- data/lib/redis_client/cluster/pub_sub.rb +22 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a8db8a7aac1f09df0c2fc3c7da3f0227246671d2fd0a199dabcda22caa0787d3
|
4
|
+
data.tar.gz: d0431f663859765f0ff3f537f4f74fcd17a72c561b615616ae5e24543bb3d3df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2023-08-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|