Skip to main content

altair_retry/
lib.rs

1//! Async retry with exponential backoff and automatic tracing.
2//!
3//! Each retry attempt runs inside a `tracing::span!` so it appears in
4//! distributed traces. If `altair-otel` is initialized in the same process,
5//! retries flow to OTLP automatically.
6//!
7//! # Example
8//!
9//! ```no_run
10//! use altair_retry::{retry, Config};
11//! use std::time::Duration;
12//!
13//! # async fn run() -> altair_retry::Result<()> {
14//! # async fn ping() -> std::io::Result<()> { Ok(()) }
15//! let cfg = Config::builder()
16//!     .name("db.connect")
17//!     .max_retries(3)
18//!     .initial_interval(Duration::from_millis(100))
19//!     .build();
20//!
21//! retry(cfg, || async { ping().await }).await?;
22//! # Ok(()) }
23//! ```
24
25#![deny(missing_docs)]
26#![forbid(unsafe_code)]
27#![warn(clippy::pedantic)]
28#![allow(clippy::module_name_repetitions)]
29#![allow(clippy::missing_errors_doc)]
30
31mod config;
32mod error;
33mod retry;
34
35pub mod prelude;
36
37pub use config::{Config, ConfigBuilder};
38pub use error::{Error, PermanentError, Result};
39pub use retry::retry;
40
41// Re-exports for one-dep ergonomics
42pub use tokio_util::sync::CancellationToken;