pub struct RetryPolicy {
pub max_number_of_attempts: u32,
pub first_retry_interval: Duration,
pub backoff_coefficient: f64,
pub max_retry_interval: Option<Duration>,
pub retry_timeout: Option<Duration>,
pub handle: Option<Arc<dyn Fn(&FailureDetails) -> bool + Send + Sync>>,
}Expand description
Policy that governs automatic retry behaviour for activities and sub-orchestrations.
Fields§
§max_number_of_attempts: u32Maximum total number of attempts (first execution + retries).
first_retry_interval: DurationDelay before the first retry.
backoff_coefficient: f64Multiplier applied to the delay on each successive retry.
1.0 means constant interval; 2.0 means exponential doubling.
max_retry_interval: Option<Duration>Upper bound on the computed delay between retries.
retry_timeout: Option<Duration>Maximum total wall-clock time spent retrying (measured from the first failure). Once elapsed, no further retries are scheduled.
handle: Option<Arc<dyn Fn(&FailureDetails) -> bool + Send + Sync>>Optional predicate called on each failure to decide whether to retry.
If None, all failures are retried (up to max_number_of_attempts).
Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new(max_number_of_attempts: u32, first_retry_interval: Duration) -> Self
pub fn new(max_number_of_attempts: u32, first_retry_interval: Duration) -> Self
Creates a simple retry policy with the given attempt count and interval.
Sourcepub fn with_backoff_coefficient(self, coefficient: f64) -> Self
pub fn with_backoff_coefficient(self, coefficient: f64) -> Self
Set the backoff coefficient (multiplier applied to the delay each retry).
Sourcepub fn with_max_retry_interval(self, interval: Duration) -> Self
pub fn with_max_retry_interval(self, interval: Duration) -> Self
Set the maximum delay between retries.
Sourcepub fn with_retry_timeout(self, timeout: Duration) -> Self
pub fn with_retry_timeout(self, timeout: Duration) -> Self
Set the maximum total wall-clock time spent retrying.
Sourcepub fn with_handle<F>(self, f: F) -> Self
pub fn with_handle<F>(self, f: F) -> Self
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
Source§impl<'de> Deserialize<'de> for RetryPolicy
impl<'de> Deserialize<'de> for RetryPolicy
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>,
Auto Trait Implementations§
impl !RefUnwindSafe for RetryPolicy
impl !UnwindSafe for RetryPolicy
impl Freeze for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin 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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request