From 5b24f15880cfd542c4e6650ca0ded2da16bc5134 Mon Sep 17 00:00:00 2001 From: Aumetra Weisman Date: Fri, 10 May 2024 22:04:21 +0200 Subject: [PATCH] Upgrade `retry-policies` (#532) --- Cargo.lock | 7 ++----- lib/just-retry/Cargo.toml | 3 +-- lib/just-retry/src/lib.rs | 7 +++---- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 17bc537aa..380f4b0fa 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3333,7 +3333,6 @@ dependencies = [ name = "just-retry" version = "0.0.1-pre.6" dependencies = [ - "chrono", "retry-policies", "tokio", "tracing", @@ -6044,12 +6043,10 @@ dependencies = [ [[package]] name = "retry-policies" -version = "0.3.0" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "493b4243e32d6eedd29f9a398896e35c6943a123b55eec97dcaee98310d25810" +checksum = "5875471e6cab2871bc150ecb8c727db5113c9338cc3354dc5ee3425b6aa40a1c" dependencies = [ - "anyhow", - "chrono", "rand 0.8.5", ] diff --git a/lib/just-retry/Cargo.toml b/lib/just-retry/Cargo.toml index b2f6b02e1..a83c122c7 100644 --- a/lib/just-retry/Cargo.toml +++ b/lib/just-retry/Cargo.toml @@ -6,8 +6,7 @@ version.workspace = true license = "MIT OR Apache-2.0" [dependencies] -chrono = { version = "0.4.38", default-features = false, features = ["std"] } -retry-policies = "0.3.0" +retry-policies = "0.4.0" tokio = { version = "1.37.0", features = ["time"] } tracing = "0.1.40" diff --git a/lib/just-retry/src/lib.rs b/lib/just-retry/src/lib.rs index e98763983..8e09d691b 100644 --- a/lib/just-retry/src/lib.rs +++ b/lib/just-retry/src/lib.rs @@ -48,11 +48,10 @@ where n_past_retries: u32, ) -> ControlFlow<(), Duration> { if let RetryDecision::Retry { execute_after } = - self.should_retry(request_start_time.as_time().into(), n_past_retries) + self.should_retry(request_start_time.as_time(), n_past_retries) { - let now = chrono::DateTime::from(SystemTime::now()); - let delta = (execute_after - now) - .to_std() + let delta = execute_after + .duration_since(SystemTime::now()) .expect("Some major clock fuckery happened"); ControlFlow::Continue(delta)