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) -> Result<Self>
pub const fn new(config: RetryConfig) -> Result<Self>
Creates a new retry manager with the given configuration.
§Errors
Returns an error if the configuration is invalid.
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.
This means cancellation may be delayed by up to one operation timeout if it occurs mid-execution.
§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 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl<E> Freeze for RetryManager<E>
impl<E> RefUnwindSafe for RetryManager<E>where
E: RefUnwindSafe,
impl<E> Send for RetryManager<E>where
E: Send,
impl<E> Sync for RetryManager<E>where
E: Sync,
impl<E> Unpin for RetryManager<E>where
E: Unpin,
impl<E> UnwindSafe for RetryManager<E>where
E: UnwindSafe,
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,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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