#client #streaming #pravega #exponential-backoff

pravega-client-retry

An internal library used by the Rust client for Pravega

8 releases

0.3.7 Feb 24, 2024
0.3.6 Oct 28, 2023
0.3.5 Aug 22, 2023
0.3.4 May 17, 2023
0.1.0 Mar 5, 2021

#4 in #pravega

Download history 6/week @ 2023-12-18 10/week @ 2023-12-25 20/week @ 2024-01-08 9/week @ 2024-01-22 22/week @ 2024-01-29 18/week @ 2024-02-05 7/week @ 2024-02-12 141/week @ 2024-02-19 325/week @ 2024-02-26 31/week @ 2024-03-04 46/week @ 2024-03-11 7/week @ 2024-03-18 1/week @ 2024-03-25 43/week @ 2024-04-01

102 downloads per month
Used in 5 crates (4 directly)

Apache-2.0

29KB
555 lines

Retry

Provides generic retry functions.


lib.rs:

Retry is a crate for retrying something that can fail with exponential backoff. It is designed to have a declarative interface for ease of use. It can be used as follows:


    #[derive(Debug, PartialEq, Eq, Snafu)]
    pub enum SnafuError {
        #[snafu(display("Retryable error"))]
        Retryable,
        #[snafu(display("NonRetryable error"))]
        Nonretryable,
    }

let retry_policy = RetryWithBackoff::default_setting().max_tries(1);
let mut collection = vec![1, 2].into_iter();
let value = retry_sync(retry_policy, || match collection.next() {
    Some(n) if n == 2 => RetryResult::Success(n),
    Some(_) => RetryResult::Retry(SnafuError::Retryable),
    None => RetryResult::Fail(SnafuError::Nonretryable),
}).unwrap();

assert_eq!(value, 2);

The above will retry the code 1 times if it throws Err(Retry::Retry). If it throws a Err(Retry::Err) or returns successfully it will return immediately. The delay following each of the filed attempts would be 1, 10,respectively. If all retries fail, it will return Err(RetryErr) that has error message.

Dependencies

~4–12MB
~102K SLoC