Trait backoff::Operation [−][src]
Operation is an operation that can be retried if it fails.
Operation is an operation that can be retried if it fails.
Required methods
Loading content...Provided methods
fn retry<B>(&mut self, backoff: &mut B) -> Result<T, Error<E>> where
B: Backoff,
[src]
B: Backoff,
Retries this operation according to the backoff policy. backoff is reset before it is used.
Examples
let mut f = || -> Result<(), Error<&str>> { // Business logic... // Give up. Err(Error::Permanent("error")) }; let mut backoff = ExponentialBackoff::default(); let _ = f.retry(&mut backoff).err().unwrap();
fn retry_notify<B, N>(
&mut self,
backoff: &mut B,
notify: N
) -> Result<T, Error<E>> where
N: Notify<E>,
B: Backoff,
[src]
&mut self,
backoff: &mut B,
notify: N
) -> Result<T, Error<E>> where
N: Notify<E>,
B: Backoff,
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 mut f = || -> Result<(), Error<&str>> { // Business logic... Err(Error::Transient("error")) }; let mut backoff = Stop{}; let _ = f.retry_notify(&mut backoff, notify).err().unwrap();