Function backoff::retry_notify
source · pub fn retry_notify<F, B, N, T, E>(
backoff: B,
op: F,
notify: N,
) -> Result<T, Error<E>>
Expand description
Retries this operation according to the backoff policy. Calls notify on failed attempts (in case of transient errors). backoff is reset before it is used.
§Examples
let notify = |err, dur| { println!("Error happened at {:?}: {}", dur, err); };
let f = || -> Result<(), Error<&str>> {
// Business logic...
Err(Error::transient("error"))
};
let backoff = Stop{};
let _ = retry_notify(backoff, f, notify).err().unwrap();