Expand description
§serdes-ai-retries
Retry strategies and error handling for serdes-ai.
This crate provides flexible retry mechanisms for handling transient failures in LLM API calls.
§Core Concepts
RetryConfig: Configure retry behaviorWaitStrategy: Define how long to wait between retriesRetryCondition: Determine which errors are retryablewith_retry: Execute operations with automatic retriesRetryClient: HTTP client with built-in retry support
§Wait Strategies
WaitStrategy::Fixed: Constant delay between attemptsWaitStrategy::ExponentialBackoff: Exponential delay with capWaitStrategy::ExponentialJitter: Exponential with randomizationWaitStrategy::Linear: Linearly increasing delayWaitStrategy::RetryAfter: Respect server’s Retry-After header
§Example
ⓘ
use serdes_ai_retries::{with_retry, RetryConfig, RetryableError};
use std::time::Duration;
let config = RetryConfig::new()
.max_retries(3)
.exponential_jitter(
Duration::from_millis(100),
Duration::from_secs(10),
0.1,
);
let result = with_retry(&config, || async {
// Your async operation
Ok::<_, RetryableError>("success")
}).await?;§HTTP Client with Retries
ⓘ
use serdes_ai_retries::RetryClient;
let client = RetryClient::for_api();
let response = client.get("https://api.example.com/data").await?;Re-exports§
pub use backoff::ExponentialBackoff;pub use backoff::ExponentialBackoffBuilder;pub use backoff::FixedDelay;pub use backoff::LinearBackoff;pub use config::RetryCondition;pub use config::RetryConfig;pub use config::WaitStrategy;pub use error::RetryResult;pub use error::RetryableError;pub use executor::with_retry;pub use executor::with_retry_state;pub use executor::AttemptInfo;pub use executor::Retry;pub use executor::RetryState;pub use strategy::NoRetry;pub use strategy::RetryStrategy;pub use transport::RetryClient;pub use transport::RetryClientBuilder;