fix: Address review comments

This commit is contained in:
timedout authored and Ellis Git committed 2026-08-20 00:57:11 +00:00
1 parent 9af60bcf62
commit f1a77e0404
9 files changed
+45 -57

No files matched your search

+1 -4
View File
@@ -37,10 +37,7 @@ pub use self::{
stream::{IterStream, ReadyExt, Tools as StreamTools, TryReadyExt},
string::{str_from_bytes, string_from_bytes},
sys::compute::available_parallelism,
time::{
exponential_backoff::should_continue_backoff, now_millis as millis_since_unix_epoch,
timepoint_ago, timepoint_from_now,
},
time::{now_millis as millis_since_unix_epoch, timepoint_ago, timepoint_from_now},
};
#[inline]
-1
View File
@@ -1,4 +1,3 @@
pub mod exponential_backoff;
pub mod jitter;
use std::time::{Duration, SystemTime, UNIX_EPOCH};
@@ -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)
}