pub async fn retry<F, Fut, T>(policy: RetryPolicy, f: F) -> Result<T>Expand description
Execute f up to policy.max_attempts times, retrying only when the
returned error is Error::is_retryable.
Non-retryable errors (e.g. authentication, validation, syntax) are
returned immediately without further attempts. Between attempts the
future sleeps for an exponentially increasing backoff capped at
RetryPolicy::max_backoff.
ยงExample
use geode_client::{retry, RetryPolicy, Error};
let result = retry(RetryPolicy::default(), || async {
// ... perform a fallible operation ...
Ok::<i32, Error>(42)
})
.await?;
assert_eq!(result, 42);