Skip to main content

Module retry

Module retry 

Source
Expand description

Retry policies and timeout-enforced task helpers.

Provides RetryPolicy for configurable retry-with-backoff and task_with_timeout / task_with_retry constructors that wrap Cmd::Task with deterministic lifecycle guarantees.

§Migration rationale

Source frameworks often have retry/timeout baked into effect middleware. These helpers give the migration code emitter explicit, testable primitives to target instead of ad-hoc retry loops.

§Determinism

Backoff delays use fixed formulas (no jitter/randomness) so that replay-based determinism tests can reproduce exact timing sequences.

§Example

use ftui_runtime::retry::{RetryPolicy, BackoffStrategy};
use std::time::Duration;

let policy = RetryPolicy::new(3, BackoffStrategy::Exponential {
    base_ms: 100,
    max_ms: 5000,
});

assert_eq!(policy.delay(0), Duration::from_millis(100));
assert_eq!(policy.delay(1), Duration::from_millis(200));
assert_eq!(policy.delay(2), Duration::from_millis(400));

Structs§

RetryPolicy
A retry policy with configurable attempts and backoff.

Enums§

BackoffStrategy
Backoff strategy for retry delays.

Functions§

task_with_retry
Create a Cmd::Task that retries on failure with the given policy.
task_with_retry_and_timeout
Create a Cmd::Task with both retry and timeout.
task_with_timeout
Create a Cmd::Task that enforces a cooperative timeout.
task_with_timeout_named
Create a Cmd::Task with a named spec and cooperative timeout.