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) -> Self

Retry the inner service depending on this Policy.

fn get_ref(&self) -> &S

Get a reference to the inner service

fn get_mut(&mut self) -> &mut S

Get a mutable reference to the inner service

fn into_inner(self) -> S

Consume 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) -> Retry<P, S>

impl<P: Debug, S: Debug> Debug for Retry<P, S>

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Auto Trait Implementations

impl<P, S> Freeze for Retry<P, S> where P: Freeze, S: Freeze,

impl<P, S> RefUnwindSafe for Retry<P, S> where P: RefUnwindSafe, S: RefUnwindSafe,

impl<P, S> Send for Retry<P, S> where P: Send, S: Send,

impl<P, S> Sync for Retry<P, S> where P: Sync, S: Sync,

impl<P, S> UnsafeUnpin for Retry<P, S> where P: UnsafeUnpin, S: UnsafeUnpin,

impl<P, S> UnwindSafe for Retry<P, S> where P: UnwindSafe, S: UnwindSafe,

Blanket Implementations

impl<C, Target> MakeConnection<Target> for Retry<P, S> where C: Service<Target>, <C as Service<Target>>::Response: AsyncRead + AsyncWrite,

type Connection = <C as Service<Target>>::Response;
type Error = <C as Service<Target>>::Error;
type Future = <C as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <C as MakeConnection<Target>>::Error>>
fn make_connection(&mut self, target: Target) -> <C as MakeConnection<Target>>::Future

impl<M, S, Target, Request> MakeService<Target, Request> for Retry<P, S> where M: Service<Target, Response = S>, S: Service<Request>,

type Response = <S as Service<Request>>::Response;
type Error = <S as Service<Request>>::Error;
type Service = S;
type MakeError = <M as Service<Target>>::Error;
type Future = <M as Service<Target>>::Future;
fn poll_ready(&mut self, cx: &mut Context<'_>) -> Poll<Result<(), <M as MakeService<Target, Request>>::MakeError>>
fn make_service(&mut self, target: Target) -> <M as MakeService<Target, Request>>::Future

impl<T> Any for Retry<P, S> where T: 'static + ?Sized,

fn type_id(&self) -> TypeId

impl<T> Borrow<T> for Retry<P, S> where T: ?Sized,

fn borrow(&self) -> &T

impl<T> BorrowMut<T> for Retry<P, S> where T: ?Sized,

fn borrow_mut(&mut self) -> &mut T

impl<T> CloneToUninit for Retry<P, S> where T: Clone,

unsafe fn clone_to_uninit(&self, dest: *mut u8)

impl<T> From<T> for Retry<P, S>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T> Instrument for Retry<P, S>

impl<T> ToOwned for Retry<P, S> where T: Clone,

type Owned = T;
fn to_owned(&self) -> T
fn clone_into(&self, target: &mut T)

impl<T> WithSubscriber for Retry<P, S>

impl<T, Request> ServiceExt<Request> for Retry<P, S> where T: Service<Request> + ?Sized,

impl<T, U> Into<U> for Retry<P, S> where U: From<T>,

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of [From]<T> for U chooses to do.

impl<T, U> TryFrom<U> for Retry<P, S> where U: Into<T>,

type Error = never;
fn try_from(value: U) -> Result<T, never>

impl<T, U> TryInto<U> for Retry<P, S> where U: TryFrom<T>,

type Error = <U as TryFrom<T>>::Error;
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>