diff --git a/Cargo.toml b/Cargo.toml index 050cf51d..516be074 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -52,7 +52,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, _ => {