Struct Retry
pub struct Retry<P, S> { /* private fields */ }
Configure retrying requests of "failed" responses.
A Policy classifies what is a "failed" response.
Clone
This middleware requires that the inner Service implements Clone,
because the Service must be stored in each ResponseFuture in
order to retry the request in the event of a failure. If the inner
Service type does not implement Clone, the Buffer middleware
can be added to make any Service cloneable.
The Policy must also implement Clone. This middleware will
clone the policy for each request session. This means a new clone
of the policy will be created for each initial request and any subsequent
retries of that request. Therefore, any state stored in the Policy instance
is for that request session only. In order to share data across request
sessions, that shared state may be stored in an Arc, so that all clones
of the Policy type reference the same instance of the shared state.
Implementations
impl<P, S> Retry<P, S>
const fn new(policy: P, service: S) -> SelfRetry the inner service depending on this
Policy.fn get_ref(&self) -> &SGet a reference to the inner service
fn get_mut(&mut self) -> &mut SGet a mutable reference to the inner service
fn into_inner(self) -> SConsume
self, returning the inner service
Trait Implementations
impl<'__pin, P, S> Unpin for Retry<P, S>
where
PinnedFieldsOf<__Origin<'__pin, P, S>>: Unpin,
impl<P, S, Request> Service<Request> for Retry<P, S>
where
P: Policy<Request, S::Response, S::Error> + Clone,
S: Service<Request> + Clone,
type Response = <S as Service<Request>>::Response;type Error = <S as Service<Request>>::Error;type Future = ResponseFuture<P, S, Request>;fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), Self::Error>>fn call(&mut self, request: Request) -> Self::Future
impl<P: Clone, S: Clone> Clone for Retry<P, S>
fn clone(&self) -> Self
impl<P: Debug, S: Debug> Debug for Retry<P, S>
fn fmt(&self, f: &mut Formatter<'_>) -> Result