mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-12-03 13:53:21 +00:00
fix: Address review comments
This commit is contained in:
1 parent
9af60bcf62
commit
f1a77e0404
9 files changed
+45
-57
No files matched your search
@@ -1,23 +0,0 @@
|
||||
use std::time::Duration;
|
||||
|
||||
/// Returns false if the backoff interval has expired based on the inputs,
|
||||
/// meaning the operation should be retried.
|
||||
#[inline]
|
||||
#[must_use]
|
||||
pub fn should_continue_backoff(
|
||||
min: Duration,
|
||||
max: Duration,
|
||||
elapsed: Duration,
|
||||
tries: u32,
|
||||
) -> bool {
|
||||
elapsed < next_interval(min, max, tries)
|
||||
}
|
||||
|
||||
/// Determines the interval that should be waited before retrying the operation
|
||||
/// using the algorithm: `(min * retries).min(max)`.
|
||||
#[must_use]
|
||||
#[inline]
|
||||
pub fn next_interval(min: Duration, max: Duration, retries: u32) -> Duration {
|
||||
// TODO(nex): jitter?
|
||||
min.saturating_mul(retries).min(max)
|
||||
}
|
||||
Reference in new issue
Block a user