pub struct RetryPolicy {
pub max_attempts: u32,
pub backoff_ms: u64,
}Expand description
Policy controlling how many times a failing node operation should be retried and how long to wait between attempts.
The inter-attempt sleep uses exponential backoff: attempt n (0-indexed)
sleeps for backoff_ms * 2^n milliseconds before being made.
§Example
use oximedia_graph::processing_graph::RetryPolicy;
// Three attempts total, starting with a 10 ms back-off.
let policy = RetryPolicy { max_attempts: 3, backoff_ms: 10 };Fields§
§max_attempts: u32Maximum number of attempts (including the first). A value of 1
means “try once; do not retry”.
backoff_ms: u64Base back-off in milliseconds. The sleep before attempt n is
backoff_ms * 2^(n-1) ms (so the first retry sleeps backoff_ms ms,
the second sleeps 2 * backoff_ms ms, and so on).
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn execute<T, E, F>(&self, f: F) -> Result<T, E>
pub fn execute<T, E, F>(&self, f: F) -> Result<T, E>
Executes f up to max_attempts times, returning the first Ok(T).
If f returns an Err(e) where e.is_transient() returns true and
there are remaining attempts, the function sleeps for an exponentially
increasing duration and then calls f again.
If f returns an Err(e) where e.is_transient() returns false,
the error is returned immediately (no further retries are made).
If all max_attempts are exhausted the last error is returned.
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 moreSource§impl Debug for RetryPolicy
impl Debug 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<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 more