Skip to content

Commit

Permalink
Update tower dependency from 0.4.13 to 0.5.1 (#722)
Browse files Browse the repository at this point in the history
  • Loading branch information
vlad1slav authored Oct 15, 2024
1 parent 180f617 commit 35f78b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -947,8 +947,8 @@ pub enum AuthState {
}

pub type OctocrabService = Buffer<
BoxService<http::Request<OctoBody>, http::Response<BoxBody<Bytes, Error>>, BoxError>,
http::Request<OctoBody>,
<BoxService<http::Request<OctoBody>, http::Response<BoxBody<Bytes, Error>>, BoxError> as tower::Service<http::Request<OctoBody>>>::Future
>;

/// The GitHub API client.
Expand Down
16 changes: 9 additions & 7 deletions src/service/middleware/retry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,21 @@ pub enum RetryConfig {
}

impl<B> Policy<Request<OctoBody>, Response<B>, Error> for RetryConfig {
type Future = futures_util::future::Ready<Self>;
type Future = futures_util::future::Ready<()>;

fn retry(
&self,
_req: &Request<OctoBody>,
result: Result<&Response<B>, &Error>,
&mut self,
_req: &mut Request<OctoBody>,
result: &mut Result<Response<B>, Error>,
) -> Option<Self::Future> {
match self {
RetryConfig::None => None,
RetryConfig::Simple(count) => match result {
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
}
Expand All @@ -35,7 +36,8 @@ impl<B> Policy<Request<OctoBody>, Response<B>, Error> for RetryConfig {
}
Err(_) => {
if *count > 0 {
Some(future::ready(RetryConfig::Simple(count - 1)))
*count -= 1;
Some(future::ready(()))
} else {
None
}
Expand All @@ -44,7 +46,7 @@ impl<B> Policy<Request<OctoBody>, Response<B>, Error> for RetryConfig {
}
}

fn clone_request(&self, req: &Request<OctoBody>) -> Option<Request<OctoBody>> {
fn clone_request(&mut self, req: &Request<OctoBody>) -> Option<Request<OctoBody>> {
match self {
RetryConfig::None => None,
_ => {
Expand Down

0 comments on commit 35f78b5

Please sign in to comment.