Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

retry: Change Policy to accept &mut self #681

Merged
merged 10 commits into from
Aug 23, 2022
Prev Previous commit
Next Next commit
Remove Unpin requirement for policy
  • Loading branch information
LucioFranco committed Aug 10, 2022
commit 416e323024b0f7a21ca545ccee1915cf3c7bd034
4 changes: 2 additions & 2 deletions tower/src/retry/future.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ where

impl<P, S, Request> Future for ResponseFuture<P, S, Request>
where
P: Policy<Request, S::Response, S::Error> + Clone + Unpin,
P: Policy<Request, S::Response, S::Error> + Clone,
S: Service<Request> + Clone,
{
type Output = Result<S::Response, S::Error>;
Expand All @@ -76,7 +76,7 @@ where
StateProj::Called { future } => {
let mut result = ready!(future.poll(cx));
if let Some(req) = &mut this.request {
match this.retry.as_mut().project().policy.retry(req, &mut result) {
match this.retry.policy.retry(req, &mut result) {
Some(checking) => {
this.state.set(State::Checking { checking });
}
Expand Down
3 changes: 1 addition & 2 deletions tower/src/retry/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ pin_project! {
/// A [`Policy`] classifies what is a "failed" response.
#[derive(Clone, Debug)]
pub struct Retry<P, S> {
#[pin]
policy: P,
service: S,
}
Expand Down Expand Up @@ -51,7 +50,7 @@ impl<P, S> Retry<P, S> {

impl<P, S, Request> Service<Request> for Retry<P, S>
where
P: Policy<Request, S::Response, S::Error> + Clone + Unpin,
P: Policy<Request, S::Response, S::Error> + Clone,
S: Service<Request> + Clone,
{
type Response = S::Response;
Expand Down