redis-cluster-client 0.4.11 → 0.4.12
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 +4 -4
- data/lib/redis_client/cluster/pub_sub.rb +13 -12
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d8eb62456ad98c03e10bf81773dfb27cfaf68b7ad8af608b13e2427e950e7379
|
4
|
+
data.tar.gz: 736117d62e45313ca6f96e97e0e3fc03093a9542315302233a55c3cde2731303
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81079a5a9985bd4fbe2b20f3ffaa5e59db4c95f9f9f184209b50ca897ab3fa3cdee8687f9be90cf46b0a371c668dff171c1f3488b3e848885d738133f0bf6e2a
|
7
|
+
data.tar.gz: 0d1e9da7b0de3cec96cb88431d2cdd935c9764c268610e4146737ae6bd7d634869a82d9425243a3c2307d7277974b1df5f3ee8d9abd78bab6169453fc724e3d3
|
@@ -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,21 +56,21 @@ 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
|
@@ -80,26 +81,26 @@ class RedisClient
|
|
80
81
|
|
81
82
|
def _call(command)
|
82
83
|
node_key = @router.find_node_key(command)
|
83
|
-
add_state(node_key)
|
84
84
|
try_call(node_key, command)
|
85
85
|
end
|
86
86
|
|
87
87
|
def try_call(node_key, command, retry_count: 1)
|
88
|
-
|
88
|
+
add_state(node_key).call(command)
|
89
89
|
rescue ::RedisClient::CommandError => e
|
90
90
|
raise if !e.message.start_with?('MOVED') || retry_count <= 0
|
91
91
|
|
92
92
|
# for sharded pub/sub
|
93
93
|
node_key = e.message.split[2]
|
94
|
-
add_state(node_key)
|
95
94
|
retry_count -= 1
|
96
95
|
retry
|
97
96
|
end
|
98
97
|
|
99
98
|
def add_state(node_key)
|
100
|
-
return @
|
99
|
+
return @state_dict[node_key] if @state_dict.key?(node_key)
|
101
100
|
|
102
|
-
|
101
|
+
state = State.new(@router.find_node(node_key).pubsub)
|
102
|
+
@state_list << state
|
103
|
+
@state_dict[node_key] = state
|
103
104
|
end
|
104
105
|
|
105
106
|
def obtain_current_time
|