#[non_exhaustive]pub struct RetryPolicy {
pub max_attempts: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
}client only.Expand description
How a failed GET is retried.
Writes are never retried; see OcpiRequest::is_retryable.
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.max_attempts: u32Total attempts, including the first. 1 disables retrying.
initial_delay: DurationThe delay before the first retry.
max_delay: DurationThe cap on the exponentially growing delay.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn delay_for(&self, attempt: u32, seed: u64) -> Duration
pub fn delay_for(&self, attempt: u32, seed: u64) -> Duration
How long to wait before attempt attempt (1-based, so the first retry is attempt 2),
for the request identified by seed.
The delay is exponential — initial_delay * 2^(attempt-1), capped at max_delay — with
equal jitter: the value actually returned is drawn from the upper half of that
interval, [base/2, base].
seed is what makes the jitter useful. A schedule computed from the attempt number alone
is identical on every client in a fleet, so a peer that has just come back from an outage
is hit by all of them at the same instant — the thundering herd that jitter exists to
prevent. Pass something that differs per client and per request;
RetryPolicy::seed_from derives one from the request’s X-Request-ID, which is a
freshly generated UUID and therefore already carries the entropy needed.
Source§impl RetryPolicy
impl RetryPolicy
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
impl Eq for RetryPolicy
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
impl StructuralPartialEq for RetryPolicy
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.