Skip to main content

exponential_backoff

Function exponential_backoff 

Source
pub fn exponential_backoff(
    base_ms: u64,
    multiplier: u64,
    exponent: u32,
    cap_ms: u64,
) -> u64
Expand description

计算指数退避(毫秒):base * multiplier^exponent,封顶 cap

§Arguments

  • base_ms - 初始退避(毫秒)
  • multiplier - 倍率(>= 1;< 1 时按 1 处理)
  • exponent - 指数(重试次数)
  • cap_ms - 上限(毫秒)