pub struct Retry<'a, E> {
pub on_retry: Option<Arc<Box<dyn Fn(RetryInfo<E>) -> Option<E> + 'a>>>,
pub until: RetryUntil,
pub backoff: Backoff,
}
Expand description
The retry builder.
Fields§
§on_retry: Option<Arc<Box<dyn Fn(RetryInfo<E>) -> Option<E> + 'a>>>
UNSTABLE“ ONLY PUBLIC FOR MACRO USE. Using the ’a to avoid needing everything to be static.
until: RetryUntil
UNSTABLE“ ONLY PUBLIC FOR MACRO USE.
backoff: Backoff
UNSTABLE“ ONLY PUBLIC FOR MACRO USE.
Implementations§
Source§impl<'a, E> Retry<'a, E>
impl<'a, E> Retry<'a, E>
Sourcepub fn until_total_attempts(self, attempts: usize) -> Self
pub fn until_total_attempts(self, attempts: usize) -> Self
Stop retrying after the given number of attempts.
Sourcepub fn until_forever(self) -> Self
pub fn until_forever(self) -> Self
Never stop retrying.
Sourcepub fn until_total_delay(self, max_total_delay: Duration) -> Self
pub fn until_total_delay(self, max_total_delay: Duration) -> Self
Stop retrying after the total delay reaches the given duration.
Sourcepub fn until_delay(self, max_delay: Duration) -> Self
pub fn until_delay(self, max_delay: Duration) -> Self
Stop retrying when the next delay is greater than the given duration.
Source§impl<'a, E> Retry<'a, E>
impl<'a, E> Retry<'a, E>
Sourcepub fn exponential(initial_delay: Duration, factor: f64) -> Self
pub fn exponential(initial_delay: Duration, factor: f64) -> Self
EXPONENTIAL: Each retry increases the delay since the last exponentially.
Creates a new exponential backoff using the given millisecond duration as the initial delay and the given exponential backoff factor (e.g. factor of 2.0 is just squared).
Sourcepub fn fibonacci(initial_delay: Duration) -> Self
pub fn fibonacci(initial_delay: Duration) -> Self
FIBONACCI: Each retry uses a delay which is the sum of the two previous delays.
Depending on the problem at hand, a fibonacci delay strategy might perform better and lead to
better throughput than the [Exponential
] strategy.
See “A Performance Comparison of Different Backoff Algorithms under Different Rebroadcast Probabilities for MANETs” for more details.
Create a new fibonacci backoff using the given duration in milliseconds.
Trait Implementations§
Auto Trait Implementations§
impl<'a, E> Freeze for Retry<'a, E>
impl<'a, E> !RefUnwindSafe for Retry<'a, E>
impl<'a, E> !Sync for Retry<'a, E>
impl<'a, E> Unpin for Retry<'a, E>
impl<'a, E> !UnwindSafe for Retry<'a, E>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T
in a tonic::Request