pub struct RetryConfig {
pub max_retries: u32,
pub initial_backoff_ms: u64,
pub retry_server_errors: bool,
pub retry_predicate: RetryPredicate,
}Expand description
Configuration for retry behavior
Controls which errors should be retried and how retries are executed.
§Examples
use odos_sdk::{RetryConfig, RetryPredicate};
// 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();
// Replace the default policy with custom logic
let config = RetryConfig {
max_retries: 2,
retry_server_errors: false,
retry_predicate: RetryPredicate::Replace(|err| {
// Custom logic to determine if error should be retried
err.is_retryable()
}),
..Default::default()
};
// Keep the default policy but veto a specific error shape
let config = RetryConfig {
retry_predicate: RetryPredicate::DefaultExcept(|err| err.is_rate_limit()),
..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: RetryPredicateHow a caller-supplied predicate composes with the default decision
tree. See RetryPredicate for the semantics of each variant.
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
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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 UnsafeUnpin 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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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