pub struct RetryConfig {
pub max_retries: u32,
pub initial_backoff_ms: u64,
pub retry_server_errors: bool,
pub retry_predicate: Option<fn(&OdosError) -> bool>,
}Expand description
Configuration for retry behavior
Controls which errors should be retried and how retries are executed.
§Examples
use odos_sdk::RetryConfig;
// No retries - all errors return immediately
let config = RetryConfig::no_retries();
// Conservative retries - only network errors
let config = RetryConfig::conservative();
// Default retries - network errors and server errors
let config = RetryConfig::default();
// Custom retry logic
let config = RetryConfig {
max_retries: 2,
retry_server_errors: false,
retry_predicate: Some(|err| {
// Custom logic to determine if error should be retried
err.is_retryable()
}),
..Default::default()
};Fields§
§max_retries: u32Maximum retry attempts for retryable errors
initial_backoff_ms: u64Initial backoff duration in milliseconds
retry_server_errors: boolWhether to retry server errors (5xx)
retry_predicate: Option<fn(&OdosError) -> bool>Custom retry predicate (advanced use)
When provided, this function overrides the default retry logic.
Return true to retry the error, false to return it immediately.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn no_retries() -> Self
pub fn no_retries() -> Self
No retries - return errors immediately
Use this when you want to handle all errors at the application level, or when implementing your own retry logic.
Sourcepub fn conservative() -> Self
pub fn conservative() -> Self
Conservative retries - only network errors
This configuration retries only transient network failures (timeouts, connection errors) but not server errors (5xx). Use this when you want to be cautious about retry behavior.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RetryConfig
impl Debug for RetryConfig
Auto Trait Implementations§
impl Freeze for RetryConfig
impl RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin for RetryConfig
impl UnwindSafe for RetryConfig
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> 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