pub struct RetryOptions { /* private fields */ }Expand description
Immutable retry option snapshot used by crate::Retry.
RetryOptions owns all executor configuration that is independent of the
application error type: attempt limits, elapsed budgets, delay strategy, and
jitter strategy. Construction validates the delay and jitter values before
an executor can use them.
Implementations§
Source§impl RetryOptions
impl RetryOptions
Sourcepub fn max_attempts(&self) -> u32
pub fn max_attempts(&self) -> u32
Sourcepub fn max_operation_elapsed(&self) -> Option<Duration>
pub fn max_operation_elapsed(&self) -> Option<Duration>
Sourcepub fn max_total_elapsed(&self) -> Option<Duration>
pub fn max_total_elapsed(&self) -> Option<Duration>
Returns maximum total retry-flow elapsed time budget.
This budget is measured with monotonic time and includes operation execution, retry sleeps, retry-after sleeps, and retry control-path listener time.
§Parameters
This method has no parameters.
§Returns
Some(Duration) for bounded executions, or None for unlimited.
§Errors
This method does not return errors.
Sourcepub fn delay(&self) -> &RetryDelay
pub fn delay(&self) -> &RetryDelay
Sourcepub fn jitter(&self) -> RetryJitter
pub fn jitter(&self) -> RetryJitter
Sourcepub fn attempt_timeout(&self) -> Option<AttemptTimeoutOption>
pub fn attempt_timeout(&self) -> Option<AttemptTimeoutOption>
Sourcepub fn worker_cancel_grace(&self) -> Duration
pub fn worker_cancel_grace(&self) -> Duration
Sourcepub fn new(
max_attempts: u32,
max_operation_elapsed: Option<Duration>,
max_total_elapsed: Option<Duration>,
delay: RetryDelay,
jitter: RetryJitter,
) -> Result<RetryOptions, RetryConfigError>
pub fn new( max_attempts: u32, max_operation_elapsed: Option<Duration>, max_total_elapsed: Option<Duration>, delay: RetryDelay, jitter: RetryJitter, ) -> Result<RetryOptions, RetryConfigError>
Creates and validates a retry option snapshot.
§Parameters
max_attempts: Maximum number of attempts, including the first call. Must be greater than zero.max_operation_elapsed: Optional cumulative user operation time budget for all attempts. Listener execution and retry sleeps are excluded.max_total_elapsed: Optional monotonic elapsed-time budget for the whole retry flow. Operation execution, retry sleeps, retry-after sleeps, and retry control-path listener time are included.delay: Base delay strategy used between attempts.jitter: RetryJitter strategy applied to each base delay.
§Returns
A validated RetryOptions value.
§Errors
Returns RetryConfigError when max_attempts is zero, or when
delay or jitter contains invalid parameters.
Sourcepub fn new_with_attempt_timeout(
max_attempts: u32,
max_operation_elapsed: Option<Duration>,
max_total_elapsed: Option<Duration>,
delay: RetryDelay,
jitter: RetryJitter,
attempt_timeout: Option<AttemptTimeoutOption>,
) -> Result<RetryOptions, RetryConfigError>
pub fn new_with_attempt_timeout( max_attempts: u32, max_operation_elapsed: Option<Duration>, max_total_elapsed: Option<Duration>, delay: RetryDelay, jitter: RetryJitter, attempt_timeout: Option<AttemptTimeoutOption>, ) -> Result<RetryOptions, RetryConfigError>
Creates and validates a retry option snapshot with attempt timeout.
§Parameters
max_attempts: Maximum number of attempts, including the first call. Must be greater than zero.max_operation_elapsed: Optional cumulative user operation time budget for all attempts. Listener execution and retry sleeps are excluded.max_total_elapsed: Optional monotonic elapsed-time budget for the whole retry flow. Operation execution, retry sleeps, retry-after sleeps, and retry control-path listener time are included.delay: Base delay strategy used between attempts.jitter: RetryJitter strategy applied to each base delay.attempt_timeout: Optional per-attempt timeout settings.
§Returns
A validated RetryOptions value.
§Errors
Returns RetryConfigError when max_attempts is zero, when delay or
jitter contains invalid parameters, or when the attempt timeout is zero.
Sourcepub fn validate(&self) -> Result<(), RetryConfigError>
pub fn validate(&self) -> Result<(), RetryConfigError>
Validates all options.
§Returns
Ok(()) when all contained strategy parameters are usable.
§Parameters
This method has no parameters.
§Errors
Returns RetryConfigError with the relevant config key when the delay
or jitter strategy is invalid.
Sourcepub fn base_delay_for_attempt(&self, attempt: u32) -> Duration
pub fn base_delay_for_attempt(&self, attempt: u32) -> Duration
Sourcepub fn delay_for_attempt(&self, attempt: u32) -> Duration
pub fn delay_for_attempt(&self, attempt: u32) -> Duration
Sourcepub fn next_base_delay_from_current(&self, current: Duration) -> Duration
pub fn next_base_delay_from_current(&self, current: Duration) -> Duration
Calculates the next base delay from the current base delay.
For exponential delay, this advances by one multiplier step from
current and caps at max. For other strategies, this delegates to the
strategy’s per-attempt base behavior.
§Parameters
current: Current base delay before jitter.
§Returns
Next base delay before jitter.
Sourcepub fn jittered_delay(&self, base_delay: Duration) -> Duration
pub fn jittered_delay(&self, base_delay: Duration) -> Duration
Trait Implementations§
Source§impl Clone for RetryOptions
impl Clone for RetryOptions
Source§fn clone(&self) -> RetryOptions
fn clone(&self) -> RetryOptions
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 RetryOptions
impl Debug for RetryOptions
Source§impl Default for RetryOptions
impl Default for RetryOptions
Source§fn default() -> RetryOptions
fn default() -> RetryOptions
Creates the default retry options.
§Returns
Options with five attempts, no cumulative user operation time limit, exponential delay, no jitter, and the default worker cancellation grace.
§Parameters
This function has no parameters.
§Errors
This function does not return errors.
§Panics
This function does not panic because the hard-coded attempt count is non-zero.
Source§impl PartialEq for RetryOptions
impl PartialEq for RetryOptions
Source§fn eq(&self, other: &RetryOptions) -> bool
fn eq(&self, other: &RetryOptions) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for RetryOptions
Auto Trait Implementations§
impl Freeze for RetryOptions
impl RefUnwindSafe for RetryOptions
impl Send for RetryOptions
impl Sync for RetryOptions
impl Unpin for RetryOptions
impl UnsafeUnpin for RetryOptions
impl UnwindSafe for RetryOptions
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, D> IntoConfigDefault<T> for Dwhere
D: IntoValueDefault<T>,
impl<T, D> IntoConfigDefault<T> for Dwhere
D: IntoValueDefault<T>,
Source§fn into_config_default(self) -> T
fn into_config_default(self) -> T
T.