mirror of
https://github.com/pezkuwichain/revive-differential-tests.git
synced 2026-07-22 01:35:45 +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]
|
[dependencies]
|
||||||
anyhow = { workspace = true }
|
anyhow = { workspace = true }
|
||||||
semver = { 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};
|
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
|
/// A function that polls for a fallible future for some period of time and errors if it fails to
|
||||||
/// get a result after polling.
|
/// get a result after polling.
|
||||||
///
|
///
|
||||||
@@ -42,6 +44,7 @@ where
|
|||||||
PollingWaitBehavior::Constant(duration) => duration,
|
PollingWaitBehavior::Constant(duration) => duration,
|
||||||
PollingWaitBehavior::ExponentialBackoff => {
|
PollingWaitBehavior::ExponentialBackoff => {
|
||||||
Duration::from_secs(2u64.pow(retries))
|
Duration::from_secs(2u64.pow(retries))
|
||||||
|
.min(EXPONENTIAL_BACKOFF_MAX_WAIT_DURATION)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let next_wait_duration =
|
let next_wait_duration =
|
||||||
|
|||||||
Reference in New Issue
Block a user