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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: be67f7c4a1a9e75573c957233bc9381745fc143b483583a4abb02b6b794bf49a
4
- data.tar.gz: b12b518ba293af7e8f84e9a8c4770c5d5e8d776e213af30db94bcba753612802
3
+ metadata.gz: 75b13bfebd7ddbbb49d37626af8bae2b0a0c21ddc7ad198856c60c502700909e
4
+ data.tar.gz: 9f8deb6e34399711ba7e432a85747272c51aa5525e3efc8d637577baab831e9e
5
5
  SHA512:
6
- metadata.gz: fa19e009a6af98f69b797a88fd0ce3e09c9cd74d0bed99fdcabf4c15e78435179736e66d5d18e0e2c66c44d6343ab75e443b3d8577b37beb91ed13065f00bf4c
7
- data.tar.gz: e055226106abe328b92d84da1f63e2d3e3ef22168cf3716837e96a7491249862894d98fa49edd92681083d6617787701411e51dab391322f1259af86a730149f
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
- msgs = collect_messages(timeout).compact
31
- return msgs.first if msgs.size < 2
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) # rubocop:disable Metrics/AbcSize
49
- @pubsub_states.each_slice(MAX_THREADS).each_with_object([]) do |chuncked_pubsub_states, acc|
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
- acc << t[:reply] unless t[:reply].nil?
61
+ @messages << t[:reply] unless t[:reply].nil?
61
62
  end
62
63
  end
63
64
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: redis-cluster-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Taishi Kasuga