pub struct RetryPolicy {
pub max_attempts: usize,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub strategy: BackoffStrategy,
pub jitter: Option<Duration>,
pub retry_error: RetryError,
}Expand description
Policy controlling retry behavior for nodes.
Fields§
§max_attempts: usizeMaximum number of attempts (including the first).
initial_backoff: DurationInitial backoff duration between retries.
max_backoff: DurationMaximum backoff duration allowed.
strategy: BackoffStrategyStrategy to compute backoff durations.
jitter: Option<Duration>Optional fixed jitter to add to each backoff.
retry_error: RetryErrorError predicate controlling which errors to retry.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(
max_attempts: usize,
initial_backoff: Duration,
max_backoff: Duration,
strategy: BackoffStrategy,
retry_error: RetryError,
) -> Self
pub fn new( max_attempts: usize, initial_backoff: Duration, max_backoff: Duration, strategy: BackoffStrategy, retry_error: RetryError, ) -> Self
Construct a new RetryPolicy.
Sourcepub fn with_jitter(self, jitter: Duration) -> Self
pub fn with_jitter(self, jitter: Duration) -> Self
Specify a fixed jitter offset to add to each backoff.
Sourcepub fn should_retry(&self, error: &FloxideError, attempt: usize) -> bool
pub fn should_retry(&self, error: &FloxideError, attempt: usize) -> bool
Determine whether an error should be retried for the given attempt (1-based).
Sourcepub fn backoff_duration(&self, attempt: usize) -> Duration
pub fn backoff_duration(&self, attempt: usize) -> Duration
Compute the backoff duration before the next retry given the attempt count (1-based).
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin 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
Mutably borrows from an owned value. Read more