refactor: fix `clippy::single_match` (#194)
parent
d95ec5a99f
commit
4e856602f6
|
@ -158,35 +158,32 @@ where
|
||||||
|
|
||||||
// We classify the response which will return None if not
|
// We classify the response which will return None if not
|
||||||
// errors were returned.
|
// errors were returned.
|
||||||
match self.retryable_strategy.handle(&result) {
|
if let Some(Retryable::Transient) = self.retryable_strategy.handle(&result) {
|
||||||
Some(Retryable::Transient) => {
|
// If the response failed and the error type was transient
|
||||||
// If the response failed and the error type was transient
|
// we can safely try to retry the request.
|
||||||
// we can safely try to retry the request.
|
let retry_decision = self.retry_policy.should_retry(start_time, n_past_retries);
|
||||||
let retry_decision = self.retry_policy.should_retry(start_time, n_past_retries);
|
if let retry_policies::RetryDecision::Retry { execute_after } = retry_decision {
|
||||||
if let retry_policies::RetryDecision::Retry { execute_after } = retry_decision {
|
let duration = execute_after
|
||||||
let duration = execute_after
|
.duration_since(SystemTime::now())
|
||||||
.duration_since(SystemTime::now())
|
.unwrap_or_else(|_| Duration::default());
|
||||||
.unwrap_or_else(|_| Duration::default());
|
// Sleep the requested amount before we try again.
|
||||||
// Sleep the requested amount before we try again.
|
#[cfg(feature = "tracing")]
|
||||||
#[cfg(feature = "tracing")]
|
log_retry!(
|
||||||
log_retry!(
|
self.retry_log_level,
|
||||||
self.retry_log_level,
|
"Retry attempt #{}. Sleeping {:?} before the next attempt",
|
||||||
"Retry attempt #{}. Sleeping {:?} before the next attempt",
|
n_past_retries,
|
||||||
n_past_retries,
|
duration
|
||||||
duration
|
);
|
||||||
);
|
#[cfg(not(target_arch = "wasm32"))]
|
||||||
#[cfg(not(target_arch = "wasm32"))]
|
tokio::time::sleep(duration).await;
|
||||||
tokio::time::sleep(duration).await;
|
#[cfg(target_arch = "wasm32")]
|
||||||
#[cfg(target_arch = "wasm32")]
|
wasm_timer::Delay::new(duration)
|
||||||
wasm_timer::Delay::new(duration)
|
.await
|
||||||
.await
|
.expect("failed sleeping");
|
||||||
.expect("failed sleeping");
|
|
||||||
|
|
||||||
n_past_retries += 1;
|
n_past_retries += 1;
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Some(_) | None => {}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Report whether we failed with or without retries.
|
// Report whether we failed with or without retries.
|
||||||
|
|
Loading…
Reference in New Issue