Skip to main content

Module retry

Module retry 

Source
Expand description

连接获取的指数退避重试策略,仅在启用 server feature 时编译。 数据库连接获取的指数退避重试策略。

取代 pool.rs 中固定 2s 间隔的重试:每次重试间隔 = base * 2^attempt, 再叠加 [0, base) 的随机 jitter,避免多请求同步重试形成惊群。 仅在 feature = "server" 时编译。

Constants§

BASE_BACKOFF 🔒
退避基准间隔(首次重试前的等待约为 base,随后翻倍)。
MAX_RETRIES
最大重试次数(不含首次尝试)。

Functions§

backoff_for
计算第 attempt 次重试(attempt 从 0 开始)前的等待时长。