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§
- Retry
Policy - Configuration for automatic retry behaviour with backoff.
Enums§
- Retry
Result - Retry result
- Retry
Strategy - Backoff algorithm applied between successive
RetryPolicyattempts.
Functions§
- retry_
if - Retry a fallible async closure only when a predicate approves the error.
- retry_
inference - Execute an inference operation with retries, honouring
RateLimitedback-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.