pub struct RetryPolicy {
pub max_retries: u32,
pub max_backoff: Duration,
pub retry_after: RetryAfterRule,
pub retry_dropped_body: bool,
}Expand description
A retry policy: how many retries, the backoff cap, the Retry-After rule, and whether a
body that fails to read is retried.
Fields§
§max_retries: u32Retries after the first attempt.
max_backoff: DurationThe backoff cap: retry n waits min(0.5s·2ⁿ, max_backoff) minus a jitter in
[0, delay/4).
retry_after: RetryAfterRuleHow Retry-After-Ms / Retry-After are honoured.
retry_dropped_body: boolWhether a body that fails while being read (a non-streaming reply, or a final error
status) is retried per should_retry_dropped_body (the Anthropic SDK) or returned as
it is (the OpenAI SDK reads bodies only after its loop).
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub const ANTHROPIC: Self
pub const ANTHROPIC: Self
The Anthropic SDK’s policy: 2 retries, 8 s backoff cap, any server wait honoured, a dropped body retried.
Sourcepub const OPENAI: Self
pub const OPENAI: Self
The OpenAI SDK’s policy: 2 retries, 8 s backoff cap, server waits up to 2 minutes, a dropped body never retried.
Sourcepub fn retry_delay(
&self,
headers: Option<&HeaderMap>,
retry_count: u32,
) -> RetryAfter
pub fn retry_delay( &self, headers: Option<&HeaderMap>, retry_count: u32, ) -> RetryAfter
The delay before retry number retry_count (0-based): the server’s decision
when parse_retry_after finds one (headers is None after a connection error or a
timed-out attempt), else min(0.5s·2^retry_count, max_backoff) minus a uniform jitter
in [0, delay/4) (rand).
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
impl Copy for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
impl Eq for RetryPolicy
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
impl StructuralPartialEq for RetryPolicy
Auto Trait Implementations§
impl Forget for RetryPolicy
impl Freeze for RetryPolicy
impl Move for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.