From 19c328e520d11f7133fb21ab898f23ce17e49734 Mon Sep 17 00:00:00 2001 From: Mingwei Samuel Date: Thu, 19 Dec 2024 09:54:52 -0800 Subject: [PATCH] cleanups for clippy --- riven/src/req/regional_requester.rs | 16 ++++++++-------- riven/src/req/token_bucket.rs | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/riven/src/req/regional_requester.rs b/riven/src/req/regional_requester.rs index 5c61eb1..b46447e 100644 --- a/riven/src/req/regional_requester.rs +++ b/riven/src/req/regional_requester.rs @@ -125,14 +125,6 @@ impl RegionalRequester { // Is retryable, do exponential backoff if retry-after wasn't specified. // 1 sec, 2 sec, 4 sec, 8 sec. match retry_after { - None => { - let delay = Duration::from_secs(2_u64.pow(retries as u32)); - log::debug!("Response {} (retried {} times), NO `retry-after`, using exponential backoff, retrying after {:?}.", status, retries, delay); - let backoff = sleep(delay); - #[cfg(feature = "tracing")] - let backoff = backoff.instrument(tracing::info_span!("backoff")); - backoff.await; - } Some(delay) => { log::debug!( "Response {} (retried {} times), `retry-after` set, retrying after {:?}.", @@ -141,6 +133,14 @@ impl RegionalRequester { delay ); } + None => { + let delay = Duration::from_secs(2_u64.pow(retries as u32)); + log::debug!("Response {} (retried {} times), NO `retry-after`, using exponential backoff, retrying after {:?}.", status, retries, delay); + let backoff = sleep(delay); + #[cfg(feature = "tracing")] + let backoff = backoff.instrument(tracing::info_span!("backoff")); + backoff.await; + } } retries += 1; } diff --git a/riven/src/req/token_bucket.rs b/riven/src/req/token_bucket.rs index ac44a73..44cb882 100644 --- a/riven/src/req/token_bucket.rs +++ b/riven/src/req/token_bucket.rs @@ -116,7 +116,7 @@ impl VectorTokenBucket { // `Instant::now()` call or something. if let Some(cutoff) = Instant::now().checked_sub(self.duration + self.duration_overhead) { // Pop off timestamps that are beyound the bucket duration. - while timestamps.back().map_or(false, |ts| *ts < cutoff) { + while timestamps.back().is_some_and(|ts| *ts < cutoff) { timestamps.pop_back(); } }