redis-cluster-client 0.4.11 → 0.4.13
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 +15 -12
- 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: 840b8fc3ccf9f870d2a5911a6b529f4ddc021e2c9ebb41f88f54c0fb324c6b89
|
4
|
+
data.tar.gz: da935ffb827910097b824247c6f308afe6177ba701be3307494628100ae85d43
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8973e3c8f747aad5e2e41649a7c3fb9787cdf8f794b7f9c9bb16225a0f15504746d9be65cc7eb0760bd6259d8e97f931ca578f3a71cc9a9c2094a8c00cf0e1f3
|
7
|
+
data.tar.gz: f13ce04e702ff896e7ab63c92f5cde997c878328bf87c539c7c764dd9c3e7b80efbf1af6edfc31946bed9d6fb69b549a60b4d7cab57d0acf4b721bf8859a9810
|
@@ -43,7 +43,8 @@ class RedisClient
|
|
43
43
|
def initialize(router, command_builder)
|
44
44
|
@router = router
|
45
45
|
@command_builder = command_builder
|
46
|
-
@
|
46
|
+
@state_list = []
|
47
|
+
@state_dict = {}
|
47
48
|
end
|
48
49
|
|
49
50
|
def call(*args, **kwargs)
|
@@ -55,24 +56,26 @@ class RedisClient
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def close
|
58
|
-
@
|
59
|
-
@
|
59
|
+
@state_list.each(&:close)
|
60
|
+
@state_list.clear
|
61
|
+
@state_dict.clear
|
60
62
|
end
|
61
63
|
|
62
64
|
def next_event(timeout = nil)
|
63
|
-
return if @
|
65
|
+
return if @state_list.empty?
|
64
66
|
|
65
67
|
max_duration = calc_max_duration(timeout)
|
66
68
|
starting = obtain_current_time
|
67
|
-
clients = @states.values
|
68
69
|
loop do
|
69
70
|
break if max_duration > 0 && obtain_current_time - starting > max_duration
|
70
71
|
|
71
|
-
|
72
|
-
|
72
|
+
@state_list.shuffle!
|
73
|
+
@state_list.each do |pubsub|
|
73
74
|
message = pubsub.take_message(timeout)
|
74
75
|
return message if message
|
75
76
|
end
|
77
|
+
|
78
|
+
sleep 0.001
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
@@ -80,26 +83,26 @@ class RedisClient
|
|
80
83
|
|
81
84
|
def _call(command)
|
82
85
|
node_key = @router.find_node_key(command)
|
83
|
-
add_state(node_key)
|
84
86
|
try_call(node_key, command)
|
85
87
|
end
|
86
88
|
|
87
89
|
def try_call(node_key, command, retry_count: 1)
|
88
|
-
|
90
|
+
add_state(node_key).call(command)
|
89
91
|
rescue ::RedisClient::CommandError => e
|
90
92
|
raise if !e.message.start_with?('MOVED') || retry_count <= 0
|
91
93
|
|
92
94
|
# for sharded pub/sub
|
93
95
|
node_key = e.message.split[2]
|
94
|
-
add_state(node_key)
|
95
96
|
retry_count -= 1
|
96
97
|
retry
|
97
98
|
end
|
98
99
|
|
99
100
|
def add_state(node_key)
|
100
|
-
return @
|
101
|
+
return @state_dict[node_key] if @state_dict.key?(node_key)
|
101
102
|
|
102
|
-
|
103
|
+
state = State.new(@router.find_node(node_key).pubsub)
|
104
|
+
@state_list << state
|
105
|
+
@state_dict[node_key] = state
|
103
106
|
end
|
104
107
|
|
105
108
|
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.13
|
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-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: redis-client
|