Ankusa.RetryPolicy.Exponential (ankusa v0.7.0)

Copy Markdown View Source

Capped binary exponential backoff with optional full jitter.

opts:

  • :base_ms — base delay (default 100)
  • :max_ms — delay ceiling before jitter (default 300_000)
  • :max_attempts — give up once attempt reaches this (default nil: no attempt limit, the horizon below is the bound)
  • :jitter — multiply the delay by a random factor in [0.5, 1.0] (default true)
  • :max_elapsed_ms — the horizon (default 86_400_000, 24 hours): dispatch dead-letters a delivery that is still failing this long after its first attempt (Ankusa.RetryPolicy.schedule/5). It is not read here; it is the same key every policy and every source's retry: uses.

Defaults retry for 24 hours: 100 ms doubling to the 5-minute cap by attempt 13, then 5 to 2.5 minutes apart (jitter halves a delay at worst), so roughly 290 to 580 attempts before the dead letter. Set max_elapsed_ms lower to dead-letter sooner, or max_attempts to bound the count.