Skip to main content

Module backoff

Module backoff 

Source
Expand description

Exponential backoff with jitter for supervisor restart strategies.

Implements the backoff algorithm described in the Janus Supervisor Architecture Refactor document:

delay = min(cap, base * 2^attempt) + jitter

Where jitter is a random value in [0, base * 2^attempt) to prevent thundering-herd scenarios when multiple services restart simultaneously after a shared outage.

§Features

  • Exponential growth with configurable base and cap
  • Full jitter to desynchronize concurrent restarts
  • Cooldown reset: if a service runs successfully for a configurable period, the attempt counter resets to zero so occasional rare failures don’t accumulate toward a long backoff
  • Circuit breaker: if a service fails N times within a window T, the supervisor can escalate (e.g., shut down the node, fire an alert)

Structs§

BackoffConfig
Configuration for the exponential backoff strategy.
BackoffState
Mutable state tracker for an individual service’s backoff history.

Enums§

BackoffAction
Result of computing the next backoff delay.