Struct sod::RetryService

source ·
pub struct RetryService<E, S, F>
where F: Fn(usize) -> Result<(), RetryError<E>>,
{ /* private fields */ }
Expand description

A Service, MutService, or AsyncService, which encapsulates a Retryable, blocking and retrying until a value is returned, an un-retryable error is encountered, or the idle function returns an Err.

When the underlying service’s Service::process function returns an Err, it is passed to the given Retryable, which must return an Ok(Input) to retry or an Err to return immediately. Between retries, the given idle function is called, given the attempt number as input, until Ok(Output) is returned by the underlying Service or Err is returned by the Retryable or idle function.

See the idle module for some provided idle functions.

Implementations§

source§

impl<E, S, F> RetryService<E, S, F>
where F: Fn(usize) -> Result<(), RetryError<E>>,

source

pub fn new(service: S, idle: F) -> Self

Trait Implementations§

source§

impl<S, F> AsyncService for RetryService<S::Error, S, F>
where S: AsyncService + Retryable<S::Input, S::Error> + Send + Sync, F: Fn(usize) -> Result<(), RetryError<S::Error>> + Send + Sync,

§

type Input = <S as AsyncService>::Input

§

type Output = <S as AsyncService>::Output

§

type Error = RetryError<<S as AsyncService>::Error>

source§

fn process<'life0, 'async_trait>( &'life0 self, input: Self::Input ) -> Pin<Box<dyn Future<Output = Result<Self::Output, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

source§

impl<S, F> Service for RetryService<S::Error, S, F>
where S: Service + Retryable<S::Input, S::Error>, F: Fn(usize) -> Result<(), RetryError<S::Error>>,

§

type Input = <S as Service>::Input

§

type Output = <S as Service>::Output

§

type Error = RetryError<<S as Service>::Error>

source§

fn process(&self, input: Self::Input) -> Result<Self::Output, Self::Error>

Process an input, producing a Result<Self::Output, Self::Error>
source§

fn into_mut(self) -> ServiceMut<Self>
where Self: Sized,

Convert this Service into a ServiceMut which impls MutService
source§

fn into_dyn<'a>(self) -> DynService<'a, Self::Input, Self::Output, Self::Error>
where Self: Sized + 'static,

Convert this Service into a DynService

Auto Trait Implementations§

§

impl<E, S, F> RefUnwindSafe for RetryService<E, S, F>

§

impl<E, S, F> Send for RetryService<E, S, F>
where F: Send, S: Send,

§

impl<E, S, F> Sync for RetryService<E, S, F>
where F: Sync, S: Sync,

§

impl<E, S, F> Unpin for RetryService<E, S, F>
where F: Unpin, S: Unpin,

§

impl<E, S, F> UnwindSafe for RetryService<E, S, F>
where F: UnwindSafe, S: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

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

Performs the conversion.