pub trait RetryExt: Future {
    fn timeout<'async_trait>(
        self,
        timeout: Duration
    ) -> Pin<Box<dyn Future<Output = Result<Self::Output, TimeoutError>> + Send + 'async_trait>>
    where
        Self: 'async_trait
; }
Expand description

An extension trait for Future that provides a convenient methods for retries.

Required Methods§

Transforms the current Future to a new one that is time-limited by the given timeout. Returns TimeoutError if timeout exceeds. Otherwise, it returns the original Future’s result. Example:

use fluvio_future::timer::sleep;
use fluvio_future::retry::RetryExt;
use fluvio_future::retry::TimeoutError;
use std::time::{Duration, Instant};

fluvio_future::task::run(async {
    let result = sleep(Duration::from_secs(10)).timeout(Duration::from_secs(1)).await;
    assert_eq!(result, Err(TimeoutError));
});

Implementors§