pub struct RetryPolicy {
pub max_attempts: u32,
pub initial_delay: Duration,
pub max_delay: Duration,
pub multiplier: f64,
pub jitter: f64,
}Expand description
Typed retry policy shared across runtime layers.
Fields§
§max_attempts: u32Maximum number of total attempts, including the initial call.
initial_delay: Duration§max_delay: Duration§multiplier: f64§jitter: f64Implementations§
Source§impl RetryPolicy
impl RetryPolicy
pub const DEFAULT: RetryPolicy
Sourcepub const DEFAULT_JITTER: f64 = 0.15
pub const DEFAULT_JITTER: f64 = 0.15
Standard jitter ratio for outbound retries: up to 15% deterministic
offset. DEFAULT keeps 0.0 so pinned delay math stays exact; call
sites that retry shared external services opt in via Self::with_jitter.
Sourcepub fn with_jitter(self, jitter: f64) -> RetryPolicy
pub fn with_jitter(self, jitter: f64) -> RetryPolicy
Builder-style jitter override, so call sites need no mut binding.
pub const fn new( max_attempts: u32, initial_delay: Duration, max_delay: Duration, multiplier: f64, ) -> RetryPolicy
pub const fn from_retries( max_retries: u32, initial_delay: Duration, max_delay: Duration, multiplier: f64, ) -> RetryPolicy
pub fn delay_for_attempt(&self, attempt_index: u32) -> Duration
pub fn decision_for_category( &self, category: ErrorCategory, attempt_index: u32, retry_after: Option<Duration>, ) -> RetryDecision
Sourcepub fn classify_anyhow(&self, error: &Error) -> RetryDecision
pub fn classify_anyhow(&self, error: &Error) -> RetryDecision
Classify an anyhow::Error for retry eligibility.
Attempt-agnostic: retryable reflects only the error category, not
the remaining attempt budget. Wire clients that manage their own
attempt counting use this; loops that want budget-aware decisions
use Self::decision_for_category.
Sourcepub fn classify_status(&self, status: u16) -> RetryDecision
pub fn classify_status(&self, status: u16) -> RetryDecision
Classify an HTTP status code for retry eligibility.
Attempt-agnostic, like Self::classify_anyhow.
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
Source§impl<'de> Deserialize<'de> for RetryPolicy
impl<'de> Deserialize<'de> for RetryPolicy
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 RetryPolicyCoreExt for RetryPolicy
impl RetryPolicyCoreExt for RetryPolicy
fn decision_for_vtcode_error( &self, error: &VtCodeError, attempt_index: u32, tool_name: Option<&str>, ) -> RetryDecision
fn decision_for_anyhow( &self, error: &Error, attempt_index: u32, tool_name: Option<&str>, ) -> RetryDecision
fn decision_for_llm_error( &self, error: &LLMError, attempt_index: u32, ) -> RetryDecision
fn decision_for_tool_error( &self, error: &UnifiedToolError, attempt_index: u32, ) -> RetryDecision
fn decision_for_tool_execution_error( &self, error: &ToolExecutionError, attempt_index: u32, ) -> RetryDecision
Source§fn step_for_vtcode_error(
&self,
error: VtCodeError,
attempt_index: u32,
tool_name: Option<&str>,
) -> RetryStep
fn step_for_vtcode_error( &self, error: VtCodeError, attempt_index: u32, tool_name: Option<&str>, ) -> RetryStep
fn apply_to_tool_execution_error( &self, error: ToolExecutionError, attempt_index: u32, tool_name: Option<&str>, ) -> ToolExecutionError
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 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
impl<T> CacheValue for 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> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> 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