pub struct RollingExponentialBackoffRetryPolicy<C, L = DefaultDebugRetryLifecycle> { /* private fields */ }
Expand description
A rolling exponential backoff retry policy.
This policy applies an exponential backoff strategy to requests that are classified as needing to be retried, and maintains a memory of how many errors have occurred prior in order to potentially alter the backoff behavior of retried requests after a successful response has been received.
§Rolling backoff behavior (recovery error decrease factor)
As responses are classified, the number of errors seen (any failed request constitutes an error) is tracked internally, which is then used to drive the exponential backoff behavior. When a request is finally successful, there are two options: reset the error count back to zero, or decrease it by some fixed amount.
If the recovery error decrease factor isn’t set at all, then the error count is reset back to zero after any successful response. This means that if our next request fails, the backoff duration would start back at a low value. If the recovery error decrease factor is set, however, then the error count is only decreased by that fixed amount after a successful response, which means that if our next request fails, the calculated backoff duration would still be reasonably close to the last calculated backoff duration.
Essentially, setting a recovery error decrease factor allows the calculated backoff duration to increase/decrease more smoothly between failed requests that occur close together.
§Missing
- Ability to set an upper bound on retry attempts before giving up.
Implementations§
Source§impl<C> RollingExponentialBackoffRetryPolicy<C>
impl<C> RollingExponentialBackoffRetryPolicy<C>
Sourcepub fn new(classifier: C, backoff: ExponentialBackoff) -> Self
pub fn new(classifier: C, backoff: ExponentialBackoff) -> Self
Creates a new RollingExponentialBackoffRetryPolicy
with the given classifier and exponential backoff strategy.
On successful responses, the error count will be reset back to zero.
Source§impl<C, L> RollingExponentialBackoffRetryPolicy<C, L>
impl<C, L> RollingExponentialBackoffRetryPolicy<C, L>
Sourcepub fn with_recovery_error_decrease_factor(self, factor: Option<u32>) -> Self
pub fn with_recovery_error_decrease_factor(self, factor: Option<u32>) -> Self
Sets the recovery error decrease factor for this policy.
The given value controls how much the error count should be decreased by after a successful response. If the
value is None
, then the error count will be reset back to zero after a successful response.
Defaults to resetting the error count to zero after a successful response.
Sourcepub fn with_retry_lifecycle<L2>(
self,
retry_lifecycle: L2,
) -> RollingExponentialBackoffRetryPolicy<C, L2>
pub fn with_retry_lifecycle<L2>( self, retry_lifecycle: L2, ) -> RollingExponentialBackoffRetryPolicy<C, L2>
Sets the retry lifecycle for this policy.
RetryLifecycle
allows defining custom hooks that are called at various points within the retry policy, such as
when a request is classified as needing to be retried, when it succeeds, and so on. This can be used to add
customized and contextual logging to retries.
Source§impl RollingExponentialBackoffRetryPolicy<StandardHttpClassifier, StandardHttpRetryLifecycle>
impl RollingExponentialBackoffRetryPolicy<StandardHttpClassifier, StandardHttpRetryLifecycle>
Sourcepub fn with_backoff(backoff: ExponentialBackoff) -> Self
pub fn with_backoff(backoff: ExponentialBackoff) -> Self
Creates a new retry policy adapted to HTTP-based clients with the given exponential backoff strategy.
This policy uses the standard HTTP classifier (StandardHttpClassifier
) and retry lifecycle (StandardHttpRetryLifecycle
).
Trait Implementations§
Source§impl<C: Clone, L: Clone> Clone for RollingExponentialBackoffRetryPolicy<C, L>
impl<C: Clone, L: Clone> Clone for RollingExponentialBackoffRetryPolicy<C, L>
Source§fn clone(&self) -> RollingExponentialBackoffRetryPolicy<C, L>
fn clone(&self) -> RollingExponentialBackoffRetryPolicy<C, L>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl<C, L, Req, Res, Error> Policy<Req, Res, Error> for RollingExponentialBackoffRetryPolicy<C, L>where
C: RetryClassifier<Res, Error>,
L: RetryLifecycle<Req, Res, Error>,
Req: Clone,
impl<C, L, Req, Res, Error> Policy<Req, Res, Error> for RollingExponentialBackoffRetryPolicy<C, L>where
C: RetryClassifier<Res, Error>,
L: RetryLifecycle<Req, Res, Error>,
Req: Clone,
Auto Trait Implementations§
impl<C, L> Freeze for RollingExponentialBackoffRetryPolicy<C, L>
impl<C, L> RefUnwindSafe for RollingExponentialBackoffRetryPolicy<C, L>where
C: RefUnwindSafe,
L: RefUnwindSafe,
impl<C, L> Send for RollingExponentialBackoffRetryPolicy<C, L>
impl<C, L> Sync for RollingExponentialBackoffRetryPolicy<C, L>
impl<C, L> Unpin for RollingExponentialBackoffRetryPolicy<C, L>
impl<C, L> UnwindSafe for RollingExponentialBackoffRetryPolicy<C, L>where
C: UnwindSafe,
L: UnwindSafe,
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> 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> 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
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> Track for T
impl<T> Track for T
Source§fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
fn track_allocations(self, token: AllocationGroupToken) -> Tracked<Self>
Tracked
wrapper. Read moreSource§fn in_current_allocation_group(self) -> Tracked<Self>
fn in_current_allocation_group(self) -> Tracked<Self>
Tracked
wrapper. Read more