+6
-2
@@ -63,11 +63,15 @@ where
|
||||
/// ```
|
||||
/// use image_api::utils::retry_with_backoff_if;
|
||||
///
|
||||
/// fn is_transient(e: &DbError) -> bool { /* ... */ }
|
||||
/// fn is_transient(e: &std::io::Error) -> bool {
|
||||
/// // Only retry connection-class failures; a NotFound is deterministic.
|
||||
/// e.kind() == std::io::ErrorKind::ConnectionRefused
|
||||
/// }
|
||||
///
|
||||
/// let result = retry_with_backoff_if("some-write", 4, is_transient, || {
|
||||
/// Ok::<_, anyhow::Error>(42)
|
||||
/// Ok::<i32, _>(42)
|
||||
/// });
|
||||
/// assert!(result.is_ok_and(|v| v == 42));
|
||||
/// ```
|
||||
pub fn retry_with_backoff_if<F, T, E, U: Fn(&E) -> bool>(
|
||||
label: &str,
|
||||
|
||||
Reference in new issue
Block a user