mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-05-09 13:37:58 +00:00
Add a maximum to the exponential backoff wait duration
This commit is contained in:
@@ -11,4 +11,4 @@ rust-version.workspace = true
|
||||
[dependencies]
|
||||
anyhow = { workspace = true }
|
||||
semver = { workspace = true }
|
||||
tokio = { workspace = true }
|
||||
tokio = { workspace = true, default-features = false, features = ["time"] }
|
||||
|
||||
@@ -3,6 +3,8 @@ use std::time::Duration;
|
||||
|
||||
use anyhow::{Result, anyhow};
|
||||
|
||||
const EXPONENTIAL_BACKOFF_MAX_WAIT_DURATION: Duration = Duration::from_secs(60);
|
||||
|
||||
/// A function that polls for a fallible future for some period of time and errors if it fails to
|
||||
/// get a result after polling.
|
||||
///
|
||||
@@ -42,6 +44,7 @@ where
|
||||
PollingWaitBehavior::Constant(duration) => duration,
|
||||
PollingWaitBehavior::ExponentialBackoff => {
|
||||
Duration::from_secs(2u64.pow(retries))
|
||||
.min(EXPONENTIAL_BACKOFF_MAX_WAIT_DURATION)
|
||||
}
|
||||
};
|
||||
let next_wait_duration =
|
||||
|
||||
Reference in New Issue
Block a user