pub struct RetryHeaderOptions<'a> { /* private fields */ }Expand description
Options for reading retry delays from response headers.
Vendor headers are read in order before the standard Retry-After header.
By default, each header value is parsed whole. Use
RetryHeaderOptions::with_first_field for APIs such as Polar that return
comma-separated quota windows and define the first field as the active one.
Parsed delays are uncapped by default, so the classifier reports what the
upstream sent. A client that schedules its own retries should set
RetryHeaderOptions::with_max_retry_after.
Use RetryHeaderOptions::with_forbidden_rate_limit for APIs such as
GitHub that also report rate limits with 403.
Implementations§
Source§impl<'a> RetryHeaderOptions<'a>
impl<'a> RetryHeaderOptions<'a>
Sourcepub const fn new(extra_retry_after_headers: &'a [&'a str]) -> Self
pub const fn new(extra_retry_after_headers: &'a [&'a str]) -> Self
Creates options that consult the named vendor headers in order.
Sourcepub const fn with_first_field(self) -> Self
pub const fn with_first_field(self) -> Self
Parses only the first comma-separated field of vendor header values.
This does not split Retry-After, whose HTTP-date form contains a
comma.
Sourcepub const fn with_max_retry_after(self, max: Duration) -> Self
pub const fn with_max_retry_after(self, max: Duration) -> Self
Clamps parsed delays to max.
An upstream that sends Retry-After: 86400 then yields max instead of
stalling a worker for a day.
Sourcepub const fn with_forbidden_rate_limit(self) -> Self
pub const fn with_forbidden_rate_limit(self) -> Self
Recognizes rate-limit headers on 403 responses.
A usable retry header gives RetryClass::RetryAfter. Otherwise,
x-ratelimit-remaining: 0 gives RetryClass::RetryAfter when
x-ratelimit-reset is a valid Unix epoch in seconds, or
RetryClass::RateLimited without a usable reset. Other 403
responses and all 401 responses stay RetryClass::Revoked.
Trait Implementations§
Source§impl<'a> Clone for RetryHeaderOptions<'a>
impl<'a> Clone for RetryHeaderOptions<'a>
impl<'a> Copy for RetryHeaderOptions<'a>
Source§impl<'a> Debug for RetryHeaderOptions<'a>
impl<'a> Debug for RetryHeaderOptions<'a>
Source§impl<'a> Default for RetryHeaderOptions<'a>
impl<'a> Default for RetryHeaderOptions<'a>
impl<'a> Eq for RetryHeaderOptions<'a>
Source§impl<'a> PartialEq for RetryHeaderOptions<'a>
impl<'a> PartialEq for RetryHeaderOptions<'a>
impl<'a> StructuralPartialEq for RetryHeaderOptions<'a>
Auto Trait Implementations§
impl<'a> Freeze for RetryHeaderOptions<'a>
impl<'a> RefUnwindSafe for RetryHeaderOptions<'a>
impl<'a> Send for RetryHeaderOptions<'a>
impl<'a> Sync for RetryHeaderOptions<'a>
impl<'a> Unpin for RetryHeaderOptions<'a>
impl<'a> UnsafeUnpin for RetryHeaderOptions<'a>
impl<'a> UnwindSafe for RetryHeaderOptions<'a>
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§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.