pub struct RetryPolicy {
pub max_retries: u32,
pub initial_backoff_ms: u64,
pub max_backoff_ms: u64,
pub jitter_ratio: f64,
pub buffered_max_bytes: u64,
}Expand description
Origin retry policy. Field-level validation lives at config-resolve
time (crates/common/src/config/mod.rs::resolve_origin_retry); this
struct just carries the values.
max_retries == 0 disables retry entirely and reproduces the
pre-issue-#285 behaviour exactly. buffered_max_bytes == 0 separately
disables the buffer-then-commit body-phase path (#519), forcing all
body-phase failures through the abort+restart streaming path.
Fields§
§max_retries: u32Number of retries after the initial attempt. Total attempts =
max_retries + 1. 0 disables retry.
initial_backoff_ms: u64Backoff before the first retry, in milliseconds. Subsequent
retries double up to max_backoff_ms.
max_backoff_ms: u64Ceiling on any single backoff sleep, in milliseconds. The exponential schedule saturates here.
jitter_ratio: f64Equal-jitter ratio in 0.0..=1.0. The actual sleep is
base * (1 - ratio/2 + rand[0,1) * ratio) so a ratio of 0.0 is
fully deterministic and 1.0 spreads the sleep uniformly over
[0.5*base, 1.5*base) — the AWS “equal jitter” recipe.
buffered_max_bytes: u64Per-fetch memory budget for the buffer-then-commit body-phase
retry path. When the origin advertises a size_hint at or
below this value, the engine drains the stream into a
BytesMut before committing — drain errors get classified
and re-feed the retry loop, so small blobs get mid-stream
retries. Above the threshold (or when size_hint is None) the
engine uses streaming abort+restart instead; memory stays
bounded but each failed
attempt strands up to max_blob_bytes of partial-import bytes
until iroh-blobs GC reclaims them.
0 disables the buffer path entirely (all body-phase failures
go through the streaming abort+restart path).
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub const fn disabled() -> RetryPolicy
pub const fn disabled() -> RetryPolicy
A policy that performs no retries: one attempt per origin.
Useful in tests and for operators who want to opt out.
Also sets buffered_max_bytes = 0 so the body-phase buffer path
is disabled in lock-step (a disabled() policy that still
buffered would surprise operators reading the field name).
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for RetryPolicy
Source§impl Debug for RetryPolicy
impl Debug for RetryPolicy
Source§impl Default for RetryPolicy
impl Default for RetryPolicy
Source§fn default() -> RetryPolicy
fn default() -> RetryPolicy
Defaults: 3 retries, 100ms initial backoff doubling to a cap of
10s, with 10% equal-jitter. Worst-case extra latency on a
fully-failing origin is ~700ms — three sleeps 100 + 200 + 400 ms
(± up to 5% jitter each) between the four total attempts.
buffered_max_bytes defaults to 4 MiB (the internal
DEFAULT_BUFFERED_MAX_BYTES constant).
Source§impl<'de> Deserialize<'de> for RetryPolicywhere
RetryPolicy: Default,
impl<'de> Deserialize<'de> for RetryPolicywhere
RetryPolicy: Default,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<RetryPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<RetryPolicy, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl PartialEq for RetryPolicy
impl PartialEq for RetryPolicy
Source§impl Serialize for RetryPolicy
impl Serialize for RetryPolicy
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl StructuralPartialEq for RetryPolicy
Auto Trait Implementations§
impl Freeze 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,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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