pub struct RetryPolicy {
pub max_retries: u32,
pub base: Duration,
pub max: Duration,
pub jitter: bool,
}Expand description
Exponential-backoff retry policy.
delay(attempt) = min(max, base * 2^(attempt-1)), optionally spread with
equal jitter (half fixed, half random) to avoid synchronized retries when
several agents hammer the same hosted endpoint.
Fields§
§max_retries: u32Number of retries after the first attempt. 0 disables retrying.
base: DurationBase delay before the first retry.
max: DurationCeiling for any single backoff delay.
jitter: boolWhether to apply equal jitter to each delay.
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Build from environment variables, falling back to RetryPolicy::default.
Variables (all optional, unset/invalid values are silently ignored):
NEWT_HTTP_MAX_RETRIES— retry count after the first attemptNEWT_HTTP_BACKOFF_BASE_MS— base delay in millisecondsNEWT_HTTP_BACKOFF_MAX_MS— ceiling delay in millisecondsNEWT_HTTP_JITTER—0/false/offdisables jitter
Sourcepub fn from_env_or(base: Self) -> Self
pub fn from_env_or(base: Self) -> Self
Sourcepub fn for_local_inference() -> Self
pub fn for_local_inference() -> Self
A policy tuned for slow, home-lab local inference endpoints (e.g. a DGX that can drop for 30–60 s under load). More patient than the default hosted-API policy:
- 6 retries (7 attempts total)
- 2 s base doubling to a 30 s ceiling, with jitter
- Total resilience window: ~90 s
Env-var overrides (NEWT_HTTP_MAX_RETRIES etc.) still apply.
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 moreSource§impl Debug for RetryPolicy
impl Debug 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
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,
impl<T> ErasedDestructor for Twhere
T: 'static,
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