| Crates.io | unistore-retry |
| lib.rs | unistore-retry |
| version | 0.1.0 |
| created_at | 2026-01-20 11:04:07.615888+00 |
| updated_at | 2026-01-20 11:04:07.615888+00 |
| description | Retry strategy capability for UniStore |
| homepage | https://github.com/yangbo1317/unistore |
| repository | https://github.com/yangbo1317/unistore |
| max_upload_size | |
| id | 2056357 |
| size | 36,100 |
重试策略能力 - UniStore 能力生态的一部分。
use unistore_retry::{retry, ExponentialBackoff};
// 使用指数退避重试
let result = retry(ExponentialBackoff::default(), || async {
fetch_data_from_api().await
}).await;
use unistore_retry::{RetryPolicy, RetryConfig};
let policy = RetryPolicy::exponential()
.max_retries(5)
.initial_delay(Duration::from_millis(100))
.max_delay(Duration::from_secs(30))
.jitter(0.1);
let result = policy.execute(|| async {
unreliable_operation().await
}).await;
use unistore_retry::{retry_if, ExponentialBackoff};
let result = retry_if(
ExponentialBackoff::default(),
|| async { api_call().await },
|err| err.is_retryable(), // 只重试特定错误
).await;
MIT OR Apache-2.0