File tree Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Expand file tree Collapse file tree 1 file changed +3
-0
lines changed Original file line number Diff line number Diff line change @@ -76,6 +76,7 @@ impl RpcMultiClient {
76
76
F : Fn ( & ' a RpcClient ) -> Pin < Box < dyn Future < Output = anyhow:: Result < T > > + Send + ' a > > ,
77
77
{
78
78
let mut attempts = 0 ;
79
+ // Try all endpoints twice in the worst case.
79
80
let max_attempts = self . rpc_clients . len ( ) * 2 ;
80
81
81
82
while attempts < max_attempts {
@@ -137,6 +138,7 @@ impl RpcMultiClient {
137
138
let index = state. current_index ;
138
139
state. current_index = ( state. current_index + 1 ) % state. endpoint_states . len ( ) ;
139
140
141
+ // Choose the next endpoint that is either healthy or has waited out the cooldown period.
140
142
#[ allow( clippy:: indexing_slicing, reason = "index is checked" ) ]
141
143
let endpoint_state = & state. endpoint_states [ index] ;
142
144
if endpoint_state. is_healthy
@@ -149,6 +151,7 @@ impl RpcMultiClient {
149
151
}
150
152
}
151
153
154
+ // If all endpoints have failed, simply move on to the next one.
152
155
if found_index. is_none ( ) {
153
156
let index = start_index;
154
157
state. current_index = ( start_index + 1 ) % state. endpoint_states . len ( ) ;
You can’t perform that action at this time.
0 commit comments