Skip to content

Commit 01d9363

Browse files
committed
minor comments
1 parent 9c55c92 commit 01d9363

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/agent/utils/rpc_multi_client.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ impl RpcMultiClient {
7676
F: Fn(&'a RpcClient) -> Pin<Box<dyn Future<Output = anyhow::Result<T>> + Send + 'a>>,
7777
{
7878
let mut attempts = 0;
79+
// Try all endpoints twice in the worst case.
7980
let max_attempts = self.rpc_clients.len() * 2;
8081

8182
while attempts < max_attempts {
@@ -137,6 +138,7 @@ impl RpcMultiClient {
137138
let index = state.current_index;
138139
state.current_index = (state.current_index + 1) % state.endpoint_states.len();
139140

141+
// Choose the next endpoint that is either healthy or has waited out the cooldown period.
140142
#[allow(clippy::indexing_slicing, reason = "index is checked")]
141143
let endpoint_state = &state.endpoint_states[index];
142144
if endpoint_state.is_healthy
@@ -149,6 +151,7 @@ impl RpcMultiClient {
149151
}
150152
}
151153

154+
// If all endpoints have failed, simply move on to the next one.
152155
if found_index.is_none() {
153156
let index = start_index;
154157
state.current_index = (start_index + 1) % state.endpoint_states.len();

0 commit comments

Comments
 (0)