pub struct RetryManager<E> { /* private fields */ }Expand description
A stateless, thread-safe retry manager for network operations.
Each execution maintains independent backoff and elapsed-time state.
Implementations§
Source§impl<E> RetryManager<E>where
E: Error,
impl<E> RetryManager<E>where
E: Error,
Sourcepub const fn new(config: RetryConfig) -> Self
pub const fn new(config: RetryConfig) -> Self
Creates a new retry manager with the given configuration.
Sourcepub fn invocation<'f1, 'f2, 'f3, 'f4, F, Fut, T, I1, I2>(
&'f1 self,
operation_name: &'f2 str,
operation: F,
should_retry: I1,
create_error: I2,
) -> RetryManagerInvocationBuilder<'f1, 'f2, 'f3, 'f4, E, F, Fut, T, I1, I2>
pub fn invocation<'f1, 'f2, 'f3, 'f4, F, Fut, T, I1, I2>( &'f1 self, operation_name: &'f2 str, operation: F, should_retry: I1, create_error: I2, ) -> RetryManagerInvocationBuilder<'f1, 'f2, 'f3, 'f4, E, F, Fut, T, I1, I2>
Returns a builder for a retry-managed invocation.
Set retry_delay to derive a minimum delay from an operation error. The retry loop uses the
greater of this minimum and the configured exponential backoff. Retry delays do not consume
the per-operation timeout. If the effective delay cannot fit within the remaining elapsed
budget, the original operation error is returned.
Set cancellation_token to cancel the operation. Cancellation is checked at three points:
- Before each operation attempt.
- During operation execution through
tokio::select!. - During retry delays.
Cancellation mid-execution takes effect immediately by dropping the in-flight operation future. For non-idempotent operations (e.g. an order already on the wire) the outcome of the abandoned attempt is unknown to the caller.
§Errors
Returns an error if:
- The operation returns a non-retryable error or exhausts the configured retries.
- An operation timeout terminates retry execution.
- The total elapsed-time budget expires.
- The backoff state cannot be created from the configuration.
- Cancellation is requested.
Trait Implementations§
Source§impl<E: Clone> Clone for RetryManager<E>
impl<E: Clone> Clone for RetryManager<E>
Source§fn clone(&self) -> RetryManager<E>
fn clone(&self) -> RetryManager<E>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more