@@ -83,60 +83,57 @@ def try_send(node, method, command, args, retry_count: 3, &block) # rubocop:disa
83
83
rescue ::RedisClient ::CircuitBreaker ::OpenCircuitError
84
84
raise
85
85
rescue ::RedisClient ::CommandError => e
86
- raise if retry_count <= 0
87
-
88
86
if e . message . start_with? ( 'MOVED' )
89
87
node = assign_redirection_node ( e . message )
90
88
retry_count -= 1
91
- retry
89
+ retry if retry_count >= 0
92
90
elsif e . message . start_with? ( 'ASK' )
93
91
node = assign_asking_node ( e . message )
94
92
node . call ( 'ASKING' )
95
93
retry_count -= 1
96
- retry
94
+ retry if retry_count >= 0
97
95
elsif e . message . start_with? ( 'CLUSTERDOWN Hash slot not served' )
98
96
update_cluster_info!
99
97
retry_count -= 1
100
- retry
101
- else
102
- raise
98
+ retry if retry_count >= 0
103
99
end
100
+ raise
104
101
rescue ::RedisClient ::ConnectionError => e
105
102
raise if METHODS_FOR_BLOCKING_CMD . include? ( method ) && e . is_a? ( RedisClient ::ReadTimeoutError )
106
- raise if retry_count <= 0
107
103
108
104
update_cluster_info!
105
+
106
+ raise if retry_count <= 0
107
+
109
108
retry_count -= 1
110
109
retry
111
110
end
112
111
113
- def try_delegate ( node , method , *args , retry_count : 3 , **kwargs , &block ) # rubocop:disable Metrics/AbcSize
112
+ def try_delegate ( node , method , *args , retry_count : 3 , **kwargs , &block ) # rubocop:disable Metrics/AbcSize, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
114
113
node . public_send ( method , *args , **kwargs , &block )
115
114
rescue ::RedisClient ::CircuitBreaker ::OpenCircuitError
116
115
raise
117
116
rescue ::RedisClient ::CommandError => e
118
- raise if retry_count <= 0
119
-
120
117
if e . message . start_with? ( 'MOVED' )
121
118
node = assign_redirection_node ( e . message )
122
119
retry_count -= 1
123
- retry
120
+ retry if retry_count >= 0
124
121
elsif e . message . start_with? ( 'ASK' )
125
122
node = assign_asking_node ( e . message )
126
123
node . call ( 'ASKING' )
127
124
retry_count -= 1
128
- retry
125
+ retry if retry_count >= 0
129
126
elsif e . message . start_with? ( 'CLUSTERDOWN Hash slot not served' )
130
127
update_cluster_info!
131
128
retry_count -= 1
132
- retry
133
- else
134
- raise
129
+ retry if retry_count >= 0
135
130
end
131
+ raise
136
132
rescue ::RedisClient ::ConnectionError
133
+ update_cluster_info!
134
+
137
135
raise if retry_count <= 0
138
136
139
- update_cluster_info!
140
137
retry_count -= 1
141
138
retry
142
139
end
0 commit comments