redis-cluster-client 0.4.5 → 0.4.6
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 +8 -7
- 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: 75b13bfebd7ddbbb49d37626af8bae2b0a0c21ddc7ad198856c60c502700909e
|
4
|
+
data.tar.gz: 9f8deb6e34399711ba7e432a85747272c51aa5525e3efc8d637577baab831e9e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 764b1ff360c46af8afebe9d937a2ac2ba3442701a4b5e9626af6157557bb29f9e35f0d0dcaff473cc77aa47b9930c6e179e42ceffa501d2105ab478e2d4f6fc8
|
7
|
+
data.tar.gz: 2eec106a7a6d0e38253ffca1f115d2a5368f3dd3c5bcfaafe25bb51bba35be67ba765dd5f6d93916d3eb23193bf4e588fe33833df8602475b58867ef8801585f
|
@@ -9,6 +9,7 @@ class RedisClient
|
|
9
9
|
@router = router
|
10
10
|
@command_builder = command_builder
|
11
11
|
@pubsub_states = {}
|
12
|
+
@messages = []
|
12
13
|
end
|
13
14
|
|
14
15
|
def call(*args, **kwargs)
|
@@ -22,15 +23,15 @@ class RedisClient
|
|
22
23
|
def close
|
23
24
|
@pubsub_states.each_value(&:close)
|
24
25
|
@pubsub_states.clear
|
26
|
+
@messages.clear
|
25
27
|
end
|
26
28
|
|
27
29
|
def next_event(timeout = nil)
|
28
30
|
return if @pubsub_states.empty?
|
31
|
+
return @messages.shift unless @messages.empty?
|
29
32
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
msgs
|
33
|
+
collect_messages(timeout)
|
34
|
+
@messages.shift
|
34
35
|
end
|
35
36
|
|
36
37
|
private
|
@@ -45,8 +46,8 @@ class RedisClient
|
|
45
46
|
pubsub.call_v(command)
|
46
47
|
end
|
47
48
|
|
48
|
-
def collect_messages(timeout)
|
49
|
-
@pubsub_states.each_slice(MAX_THREADS)
|
49
|
+
def collect_messages(timeout)
|
50
|
+
@pubsub_states.each_slice(MAX_THREADS) do |chuncked_pubsub_states|
|
50
51
|
threads = chuncked_pubsub_states.map do |_, v|
|
51
52
|
Thread.new(v) do |pubsub|
|
52
53
|
Thread.current[:reply] = pubsub.next_event(timeout)
|
@@ -57,7 +58,7 @@ class RedisClient
|
|
57
58
|
|
58
59
|
threads.each do |t|
|
59
60
|
t.join
|
60
|
-
|
61
|
+
@messages << t[:reply] unless t[:reply].nil?
|
61
62
|
end
|
62
63
|
end
|
63
64
|
end
|