pub struct RetryManager<E> { /* private fields */ }Expand description
Generic retry manager for network operations.
Stateless and thread-safe - each operation maintains its own backoff 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 async fn execute_with_retry_inner<F, Fut, T>(
&self,
operation_name: &str,
operation: F,
should_retry: impl Fn(&E) -> bool,
create_error: impl Fn(String) -> E,
cancel: Option<&CancellationToken>,
) -> Result<T, E>
pub async fn execute_with_retry_inner<F, Fut, T>( &self, operation_name: &str, operation: F, should_retry: impl Fn(&E) -> bool, create_error: impl Fn(String) -> E, cancel: Option<&CancellationToken>, ) -> Result<T, E>
Executes an operation with retry logic and optional cancellation.
Cancellation is checked at three points:
(1) Before each operation attempt.
(2) During operation execution (via tokio::select!).
(3) 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 fails after exhausting all retries, if the operation times out, if creating the backoff state fails, or if canceled.
Sourcepub async fn execute_with_retry<F, Fut, T>(
&self,
operation_name: &str,
operation: F,
should_retry: impl Fn(&E) -> bool,
create_error: impl Fn(String) -> E,
) -> Result<T, E>
pub async fn execute_with_retry<F, Fut, T>( &self, operation_name: &str, operation: F, should_retry: impl Fn(&E) -> bool, create_error: impl Fn(String) -> E, ) -> Result<T, E>
Executes an operation with retry logic.
§Errors
Returns an error if the operation fails after exhausting all retries, if the operation times out, or if creating the backoff state fails.
Sourcepub async fn execute_with_retry_with_cancel<F, Fut, T>(
&self,
operation_name: &str,
operation: F,
should_retry: impl Fn(&E) -> bool,
create_error: impl Fn(String) -> E,
cancellation_token: &CancellationToken,
) -> Result<T, E>
pub async fn execute_with_retry_with_cancel<F, Fut, T>( &self, operation_name: &str, operation: F, should_retry: impl Fn(&E) -> bool, create_error: impl Fn(String) -> E, cancellation_token: &CancellationToken, ) -> Result<T, E>
Executes an operation with retry logic and cancellation support.
§Errors
Returns an error if the operation fails after exhausting all retries, if the operation times out, if creating the backoff state fails, or if canceled.
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