pub struct WaitStrategyConfig<T> {
pub max_attempts: Option<usize>,
pub initial_delay: Duration,
pub max_delay: Duration,
pub backoff_rate: f64,
pub jitter: JitterStrategy,
pub should_continue_polling: Box<dyn Fn(&T) -> bool + Send + Sync>,
}Expand description
Configuration for creating a wait strategy.
This struct holds all the parameters needed to build a wait strategy function
via create_wait_strategy. The resulting function can be used with
WaitForConditionConfig to control
polling behavior with backoff, jitter, and a custom predicate.
§Type Parameters
T: The state type returned by the condition check function.
§Example
use durable_execution_sdk::config::{WaitStrategyConfig, JitterStrategy, create_wait_strategy, WaitDecision};
use durable_execution_sdk::Duration;
let config = WaitStrategyConfig {
max_attempts: Some(10),
initial_delay: Duration::from_seconds(5),
max_delay: Duration::from_seconds(300),
backoff_rate: 1.5,
jitter: JitterStrategy::Full,
should_continue_polling: Box::new(|state: &String| state != "COMPLETED"),
};
let strategy = create_wait_strategy(config);
// strategy(&"COMPLETED".to_string(), 1) => WaitDecision::DoneFields§
§max_attempts: Option<usize>Maximum number of polling attempts. None defaults to 60.
initial_delay: DurationInitial delay between polls.
max_delay: DurationMaximum delay cap.
backoff_rate: f64Backoff multiplier applied per attempt.
jitter: JitterStrategyJitter strategy applied to the computed delay.
should_continue_polling: Box<dyn Fn(&T) -> bool + Send + Sync>Predicate that returns true if polling should continue, false if the condition is met.
Auto Trait Implementations§
impl<T> Freeze for WaitStrategyConfig<T>
impl<T> !RefUnwindSafe for WaitStrategyConfig<T>
impl<T> Send for WaitStrategyConfig<T>
impl<T> Sync for WaitStrategyConfig<T>
impl<T> Unpin for WaitStrategyConfig<T>
impl<T> UnsafeUnpin for WaitStrategyConfig<T>
impl<T> !UnwindSafe for WaitStrategyConfig<T>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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 moreCreates a shared type from an unshared type.