pub struct BackoffPolicy {
pub jitter: JitterPolicy,
pub first_ms: u64,
pub max_ms: u64,
pub factor: f64,
}Expand description
Exponential backoff configuration for task restart delays.
| Field | Type | Default | Description |
|---|---|---|---|
jitter | JitterPolicy | Full | Randomness applied to each delay |
first_ms | u64 | 1_000 | Initial delay (ms) |
max_ms | u64 | 30_000 | Maximum delay cap (ms) |
factor | f64 | 2.0 | Exponential growth multiplier |
Before jitter, factor 2.0 grows 1s, 2s, 4s, 8s.
Growth stops at max_ms.
§Example
use solti_model::{BackoffPolicy, JitterPolicy};
let backoff = BackoffPolicy {
jitter: JitterPolicy::Equal,
first_ms: 1_000,
max_ms: 30_000,
factor: 2.0,
};
backoff.validate().unwrap();Fields§
§jitter: JitterPolicyJitter policy applied to each computed delay.
first_ms: u64Initial delay (ms) for exponential backoff.
max_ms: u64Maximum allowed delay (ms).
factor: f64Exponential growth multiplier.
Implementations§
Source§impl BackoffPolicy
impl BackoffPolicy
Sourcepub fn validate(&self) -> ModelResult<()>
pub fn validate(&self) -> ModelResult<()>
Validates backoff parameters.
§Errors
Returns ModelError::Invalid when first_ms is zero,
max_ms is below first_ms, or factor is not finite or below 1.0.
§Example
use solti_model::BackoffPolicy;
let mut backoff = BackoffPolicy::default();
backoff.first_ms = 0;
assert!(backoff.validate().is_err());Trait Implementations§
Source§impl Clone for BackoffPolicy
impl Clone for BackoffPolicy
Source§fn clone(&self) -> BackoffPolicy
fn clone(&self) -> BackoffPolicy
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for BackoffPolicy
impl Debug for BackoffPolicy
Source§impl Default for BackoffPolicy
impl Default for BackoffPolicy
Source§impl<'de> Deserialize<'de> for BackoffPolicy
impl<'de> Deserialize<'de> for BackoffPolicy
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>,
Deserialize this value from the given Serde deserializer. Read more
impl Eq for BackoffPolicy
Source§impl Hash for BackoffPolicy
impl Hash for BackoffPolicy
Source§impl JsonSchema for BackoffPolicy
impl JsonSchema for BackoffPolicy
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for BackoffPolicy
impl PartialEq for BackoffPolicy
Auto Trait Implementations§
impl Freeze for BackoffPolicy
impl RefUnwindSafe for BackoffPolicy
impl Send for BackoffPolicy
impl Sync for BackoffPolicy
impl Unpin for BackoffPolicy
impl UnsafeUnpin for BackoffPolicy
impl UnwindSafe for BackoffPolicy
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