pub struct LlmRetryConfig {
pub max_retries: u32,
pub initial_backoff: Duration,
pub max_backoff: Duration,
pub backoff_multiplier: f64,
pub jitter_factor: f64,
}Expand description
Configuration for LLM rate limit retry behavior.
Defaults match official Anthropic/OpenAI SDK behavior:
- max_retries: 2
- initial_backoff: 1 second
- max_backoff: 60 seconds
- backoff_multiplier: 2.0
- jitter_factor: 0.25 (±25%)
Fields§
§max_retries: u32Maximum number of retry attempts (0 = no retries)
initial_backoff: DurationInitial backoff duration (before exponential increase)
max_backoff: DurationMaximum backoff duration (cap for exponential growth)
backoff_multiplier: f64Backoff multiplier (typically 2.0 for exponential)
jitter_factor: f64Jitter factor (0.0-1.0, adds randomness to avoid thundering herd) Official SDKs use 0.25 (±25%)
Implementations§
Source§impl LlmRetryConfig
impl LlmRetryConfig
Sourcepub fn no_retry() -> LlmRetryConfig
pub fn no_retry() -> LlmRetryConfig
Create a config with no retries (fail immediately on rate limit)
Sourcepub fn aggressive() -> LlmRetryConfig
pub fn aggressive() -> LlmRetryConfig
Create a config with aggressive retry settings (more retries, longer waits)
Sourcepub fn calculate_backoff(&self, attempt: u32) -> Duration
pub fn calculate_backoff(&self, attempt: u32) -> Duration
Calculate backoff duration for a given attempt number (0-indexed)
Trait Implementations§
Source§impl Clone for LlmRetryConfig
impl Clone for LlmRetryConfig
Source§fn clone(&self) -> LlmRetryConfig
fn clone(&self) -> LlmRetryConfig
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 LlmRetryConfig
impl Debug for LlmRetryConfig
Source§impl Default for LlmRetryConfig
impl Default for LlmRetryConfig
Source§fn default() -> LlmRetryConfig
fn default() -> LlmRetryConfig
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for LlmRetryConfig
impl RefUnwindSafe for LlmRetryConfig
impl Send for LlmRetryConfig
impl Sync for LlmRetryConfig
impl Unpin for LlmRetryConfig
impl UnsafeUnpin for LlmRetryConfig
impl UnwindSafe for LlmRetryConfig
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request