madruga

Crates.iomadruga
lib.rsmadruga
version0.1.3
created_at2025-03-18 23:12:26.835096+00
updated_at2025-03-18 23:23:21.875804+00
descriptionRetry resiliente com backoff.
homepage
repositoryhttps://github.com/brenogonzaga/madruga
max_upload_size
id1597452
size27,752
Breno Gonzaga (brenogonzaga)

documentation

README

madruga

Resilient retry with laziness.

A crate for those who need retries with backoff — but with style. madruga attempts to solve problems, but only as far as it's worth it.

Features

  • Backoff strategies (fixed, exponential, jitter)
  • Ease of use with retry_async
  • Optional humorous messages
  • Compatible with tokio

Basic Example

use madruga::{backoff::Backoff, madruga_retry, RetryResult, RetryStrategy};
use std::time::Duration;

#[tokio::main]
async fn main() {
    let strategy = RetryStrategy::new(3, Backoff::Fixed(Duration::from_secs(1)));

    async fn retry_operation() -> Result<(), &'static str> {
        Err("Simple failure")
    }

    let result: RetryResult<_, _> = madruga_retry!(strategy, || retry_operation).await;

    match result {
        RetryResult::Success(val) => println!("Success: {:?}", val),
        RetryResult::Failure(e) => println!("Error: {}", e),
    }
}

Commit count: 3

cargo fmt