refactor(core): use idiomatic .min() in calculate_delay (#16314)

This commit is contained in:
Chang Su
2026-01-02 15:46:13 -08:00
committed by GitHub
parent bd9a2ced47
commit 2f623368ab

View File

@@ -27,10 +27,7 @@ impl BackoffCalculator {
/// Calculate backoff delay for a given attempt index (0-based).
pub fn calculate_delay(config: &RetryConfig, attempt: u32) -> Duration {
let pow = config.backoff_multiplier.powi(attempt as i32);
let mut delay_ms = (config.initial_backoff_ms as f32 * pow) as u64;
if delay_ms > config.max_backoff_ms {
delay_ms = config.max_backoff_ms;
}
let delay_ms = ((config.initial_backoff_ms as f32 * pow) as u64).min(config.max_backoff_ms);
let jitter = config.jitter_factor.clamp(0.0, 1.0);
if jitter > 0.0 {