pub struct RetryConfig {
pub attempts: u32,
pub delay: HumanDuration,
pub max_delay: HumanDuration,
pub max_elapsed: Option<HumanDuration>,
}Expand description
User-facing retry configuration block (retry: at config root).
All fields are optional in YAML; missing fields fall back to the defaults (10 attempts, 10s base delay, 5m cap).
Fields§
§attempts: u32Total attempts (including the first). Default 10. Values < 1 are
clamped up to 1 by the policy layer.
delay: HumanDurationInitial delay before the second attempt. Default 10s. Subsequent
delays grow exponentially (delay × 2^(n-2)) up to Self::max_delay.
max_delay: HumanDurationUpper bound on any individual sleep between attempts. Default 5m.
Without this cap, an exponential backoff with delay=10s would
stretch attempt 9 to ~42 minutes.
max_elapsed: Option<HumanDuration>Cap on TOTAL retry wall-time across all attempts of a single operation.
Retrying stops before a backoff sleep would push elapsed time past this
budget, so a long transient storm fails cleanly (with the last error,
resumable on an idempotent re-run) instead of running the full attempt
ladder. Unset (field default None) resolves to a 15-minute budget
(crate::retry::DEFAULT_MAX_ELAPSED); set it to raise or lower that
ceiling. A publisher honors this budget by threading
crate::context::Context::retry_deadline into its retry ladder; those whose
surrounding CI job has a hard timeout should keep it below that timeout.
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub const DEFAULT_ATTEMPTS: u32 = 10
pub const DEFAULT_ATTEMPTS: u32 = 10
Default attempt count (10).
Sourcepub const DEFAULT_DELAY: Duration
pub const DEFAULT_DELAY: Duration
Default initial delay (10s).
Sourcepub const DEFAULT_MAX_DELAY: Duration
pub const DEFAULT_MAX_DELAY: Duration
Default delay cap (5m).
Sourcepub fn to_policy(&self) -> RetryPolicy
pub fn to_policy(&self) -> RetryPolicy
Bridge to the internal RetryPolicy consumed by
crate::retry::retry_sync / crate::retry::retry_async.
If max_delay < delay, every backoff is immediately capped to
max_delay. This is parity-correct passthrough
but almost certainly a config mistake, so a tracing::warn! fires
once at conversion time to surface the issue in logs.
Sourcepub fn max_elapsed_duration(&self) -> Option<Duration>
pub fn max_elapsed_duration(&self) -> Option<Duration>
The configured total-retry-wall-time budget, if any.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
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 RetryConfig
Source§impl Debug for RetryConfig
impl Debug for RetryConfig
Source§impl Default for RetryConfig
impl Default for RetryConfig
Source§impl<'de> Deserialize<'de> for RetryConfigwhere
RetryConfig: Default,
impl<'de> Deserialize<'de> for RetryConfigwhere
RetryConfig: Default,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for RetryConfig
impl JsonSchema for RetryConfig
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref keyword. Read more