Skip to main content

Crate serdes_ai_retries

Crate serdes_ai_retries 

Source
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

§Wait Strategies

§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;

Modules§

backoff
Backoff strategies.
config
Retry configuration.
error
Retry error types.
executor
Retry executor for running operations with retries.
prelude
Prelude for common imports.
strategy
Retry strategy trait.
transport
HTTP transport with automatic retries.