redis-cluster-client 0.4.10 → 0.4.12

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: a8db8a7aac1f09df0c2fc3c7da3f0227246671d2fd0a199dabcda22caa0787d3
4
- data.tar.gz: d0431f663859765f0ff3f537f4f74fcd17a72c561b615616ae5e24543bb3d3df
3
+ metadata.gz: d8eb62456ad98c03e10bf81773dfb27cfaf68b7ad8af608b13e2427e950e7379
4
+ data.tar.gz: 736117d62e45313ca6f96e97e0e3fc03093a9542315302233a55c3cde2731303
5
5
  SHA512:
6
- metadata.gz: bed8b8bc6f6321808fcee27b30c43746eca124abad25bbdb7923bc6b6faf56cb53343008fcf4648d4be56df42d7e8baa1a105206ff6a7370dae9c528bf7213cc
7
- data.tar.gz: 1ee8f2edc8207011ccdda3a3d863895adc5ae0f3747b4b62374a96cbb19779f00b13fb350aa519a38083708da250f0e3249667c0a8dbaaeaf07781f2dcf0cbdd
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
- @states = {}
46
+ @state_list = []
47
+ @state_dict = {}
47
48
  end
48
49
 
49
50
  def call(*args, **kwargs)
@@ -55,19 +56,21 @@ class RedisClient
55
56
  end
56
57
 
57
58
  def close
58
- @states.each_value(&:close)
59
- @states.clear
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 @states.empty?
65
+ return if @state_list.empty?
64
66
 
65
67
  max_duration = calc_max_duration(timeout)
66
68
  starting = obtain_current_time
67
69
  loop do
68
70
  break if max_duration > 0 && obtain_current_time - starting > max_duration
69
71
 
70
- @states.values.shuffle.each do |pubsub|
72
+ @state_list.shuffle!
73
+ @state_list.each do |pubsub|
71
74
  message = pubsub.take_message(timeout)
72
75
  return message if message
73
76
  end
@@ -78,26 +81,26 @@ class RedisClient
78
81
 
79
82
  def _call(command)
80
83
  node_key = @router.find_node_key(command)
81
- add_state(node_key)
82
84
  try_call(node_key, command)
83
85
  end
84
86
 
85
87
  def try_call(node_key, command, retry_count: 1)
86
- @states[node_key].call(command)
88
+ add_state(node_key).call(command)
87
89
  rescue ::RedisClient::CommandError => e
88
90
  raise if !e.message.start_with?('MOVED') || retry_count <= 0
89
91
 
90
92
  # for sharded pub/sub
91
93
  node_key = e.message.split[2]
92
- add_state(node_key)
93
94
  retry_count -= 1
94
95
  retry
95
96
  end
96
97
 
97
98
  def add_state(node_key)
98
- return @states[node_key] if @states.key?(node_key)
99
+ return @state_dict[node_key] if @state_dict.key?(node_key)
99
100
 
100
- @states[node_key] = State.new(@router.find_node(node_key).pubsub)
101
+ state = State.new(@router.find_node(node_key).pubsub)
102
+ @state_list << state
103
+ @state_dict[node_key] = state
101
104
  end
102
105
 
103
106
  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.10
4
+ version: 0.4.12
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 00:00:00.000000000 Z
11
+ date: 2023-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: redis-client