Skip to main content

Module retry

Module retry 

Source
Expand description

Retry Logic

Automatic retry with exponential backoff for transient failures.

§Usage

use std::time::Duration;
use tokio_prompt_orchestrator::enhanced::RetryPolicy;
let policy = RetryPolicy::exponential(3, Duration::from_millis(100));

let result = policy.retry(|| async {
    // Your fallible operation — returns Ok on success, Err on transient failure
    Ok::<String, std::io::Error>("inference result".to_string())
}).await;

match result {
    Ok(output) => println!("{output}"),
    Err(e) => eprintln!("All retries exhausted: {e}"),
}

Structs§

RetryPolicy
Configuration for automatic retry behaviour with backoff.

Enums§

RetryResult
Retry result
RetryStrategy
Backoff algorithm applied between successive RetryPolicy attempts.

Functions§

retry_if
Retry a fallible async closure only when a predicate approves the error.
retry_inference
Execute an inference operation with retries, honouring RateLimited back-off.
with_jitter
Add random jitter (up to 25 %) to a delay to prevent thundering-herd scenarios when many clients retry at the same time.