pub struct RetryConfigBuilder<E> { /* private fields */ }Expand description
Builder for RetryConfig.
Implementations§
Source§impl<E> RetryConfigBuilder<E>
impl<E> RetryConfigBuilder<E>
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder with defaults.
Defaults:
- max_attempts: 3
- backoff: Exponential with 100ms initial interval
- name:
"<unnamed>"
Sourcepub fn max_attempts(self, max_attempts: usize) -> Self
pub fn max_attempts(self, max_attempts: usize) -> Self
Sets the maximum number of retry attempts.
This includes the initial attempt, so max_attempts=3 means 1 initial attempt + 2 retries.
Sourcepub fn fixed_backoff(self, duration: Duration) -> Self
pub fn fixed_backoff(self, duration: Duration) -> Self
Sets a fixed backoff interval.
Sourcepub fn exponential_backoff(self, initial_interval: Duration) -> Self
pub fn exponential_backoff(self, initial_interval: Duration) -> Self
Sets exponential backoff with default settings.
Sourcepub fn backoff<I>(self, interval_fn: I) -> Selfwhere
I: IntervalFunction + 'static,
pub fn backoff<I>(self, interval_fn: I) -> Selfwhere
I: IntervalFunction + 'static,
Sets a custom interval function for backoff.
Sourcepub fn retry_on<F>(self, predicate: F) -> Self
pub fn retry_on<F>(self, predicate: F) -> Self
Sets a predicate to determine which errors should be retried.
Sourcepub fn name<S: Into<String>>(self, name: S) -> Self
pub fn name<S: Into<String>>(self, name: S) -> Self
Sets the name for this retry instance (used in events).
Sourcepub fn on_success<F>(self, f: F) -> Self
pub fn on_success<F>(self, f: F) -> Self
Registers a callback for success events.
Sourcepub fn on_error<F>(self, f: F) -> Self
pub fn on_error<F>(self, f: F) -> Self
Registers a callback for error events (exhausted retries).
Sourcepub fn on_ignored_error<F>(self, f: F) -> Self
pub fn on_ignored_error<F>(self, f: F) -> Self
Registers a callback for ignored error events.
Sourcepub fn build(self) -> RetryConfig<E>
pub fn build(self) -> RetryConfig<E>
Builds the retry configuration.
Trait Implementations§
Auto Trait Implementations§
impl<E> Freeze for RetryConfigBuilder<E>
impl<E> !RefUnwindSafe for RetryConfigBuilder<E>
impl<E> Send for RetryConfigBuilder<E>
impl<E> Sync for RetryConfigBuilder<E>
impl<E> Unpin for RetryConfigBuilder<E>
impl<E> UnsafeUnpin for RetryConfigBuilder<E>
impl<E> !UnwindSafe for RetryConfigBuilder<E>
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