From 35f78b5c07a20ea31f4b4648d1ecc65bf6b09863 Mon Sep 17 00:00:00 2001 From: Vlad <2307665+vlad1slav@users.noreply.github.com> Date: Wed, 16 Oct 2024 01:09:12 +0300 Subject: [PATCH] Update tower dependency from 0.4.13 to 0.5.1 (#722) --- Cargo.toml | 2 +- src/lib.rs | 2 +- src/service/middleware/retry.rs | 16 +++++++++------- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 383a77c1..b1fdb22c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,7 +57,7 @@ serde_path_to_error = "0.1.4" serde_urlencoded = "0.7.1" snafu = "0.8" tokio = { version = "1.17.0", default-features = false, features = ["time"], optional = true } -tower = { version = "0.4.13", default-features = false, features = ["util", "buffer"] } +tower = { version = "0.5.1", default-features = false, features = ["util", "buffer"] } tower-http = { version = "0.6.1", features = ["map-response-body", "trace"] } tracing = { version = "0.1.37", features = ["log"], optional = true } url = { version = "2.2.2", features = ["serde"] } diff --git a/src/lib.rs b/src/lib.rs index 6f8220a5..f1aae9ac 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -947,8 +947,8 @@ pub enum AuthState { } pub type OctocrabService = Buffer< - BoxService, http::Response>, BoxError>, http::Request, + , http::Response>, BoxError> as tower::Service>>::Future >; /// The GitHub API client. diff --git a/src/service/middleware/retry.rs b/src/service/middleware/retry.rs index a0c8ed62..2e38564f 100644 --- a/src/service/middleware/retry.rs +++ b/src/service/middleware/retry.rs @@ -12,12 +12,12 @@ pub enum RetryConfig { } impl Policy, Response, Error> for RetryConfig { - type Future = futures_util::future::Ready; + type Future = futures_util::future::Ready<()>; fn retry( - &self, - _req: &Request, - result: Result<&Response, &Error>, + &mut self, + _req: &mut Request, + result: &mut Result, Error>, ) -> Option { match self { RetryConfig::None => None, @@ -25,7 +25,8 @@ impl Policy, Response, Error> for RetryConfig { Ok(response) => { if response.status().is_server_error() || response.status() == 429 { if *count > 0 { - Some(future::ready(RetryConfig::Simple(count - 1))) + *count -= 1; + Some(future::ready(())) } else { None } @@ -35,7 +36,8 @@ impl Policy, Response, Error> for RetryConfig { } Err(_) => { if *count > 0 { - Some(future::ready(RetryConfig::Simple(count - 1))) + *count -= 1; + Some(future::ready(())) } else { None } @@ -44,7 +46,7 @@ impl Policy, Response, Error> for RetryConfig { } } - fn clone_request(&self, req: &Request) -> Option> { + fn clone_request(&mut self, req: &Request) -> Option> { match self { RetryConfig::None => None, _ => {