| Crates.io | madruga |
| lib.rs | madruga |
| version | 0.1.3 |
| created_at | 2025-03-18 23:12:26.835096+00 |
| updated_at | 2025-03-18 23:23:21.875804+00 |
| description | Retry resiliente com backoff. |
| homepage | |
| repository | https://github.com/brenogonzaga/madruga |
| max_upload_size | |
| id | 1597452 |
| size | 27,752 |
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.
retry_asynctokiouse 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),
}
}