redis-cluster-client 0.4.4 → 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 -5
- 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,13 +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
|
-
|
29
|
-
return
|
30
|
+
return if @pubsub_states.empty?
|
31
|
+
return @messages.shift unless @messages.empty?
|
30
32
|
|
31
|
-
|
33
|
+
collect_messages(timeout)
|
34
|
+
@messages.shift
|
32
35
|
end
|
33
36
|
|
34
37
|
private
|
@@ -44,7 +47,7 @@ class RedisClient
|
|
44
47
|
end
|
45
48
|
|
46
49
|
def collect_messages(timeout)
|
47
|
-
@pubsub_states.each_slice(MAX_THREADS)
|
50
|
+
@pubsub_states.each_slice(MAX_THREADS) do |chuncked_pubsub_states|
|
48
51
|
threads = chuncked_pubsub_states.map do |_, v|
|
49
52
|
Thread.new(v) do |pubsub|
|
50
53
|
Thread.current[:reply] = pubsub.next_event(timeout)
|
@@ -55,7 +58,7 @@ class RedisClient
|
|
55
58
|
|
56
59
|
threads.each do |t|
|
57
60
|
t.join
|
58
|
-
|
61
|
+
@messages << t[:reply] unless t[:reply].nil?
|
59
62
|
end
|
60
63
|
end
|
61
64
|
end
|