ConduitMcp.Client.Backoff (ConduitMCP v0.11.0)

Copy Markdown View Source

Reconnect delays for ConduitMcp.Client.

full_jitter/2 is the default :backoff of ConduitMcp.Client.Config: a uniformly random delay between 1 ms and min(cap, base * 2 ** attempt) ("full jitter"), so many clients that lost the same server do not reconnect in lockstep. attempt is 1 for the first reconnect.

Summary

Functions

A full-jitter exponential delay in milliseconds for reconnect attempt.

Functions

full_jitter(attempt, opts \\ [])

@spec full_jitter(non_neg_integer(), keyword()) :: pos_integer()

A full-jitter exponential delay in milliseconds for reconnect attempt.

Options

  • :base - the first step, in milliseconds (default 500).
  • :cap - the largest delay, in milliseconds (default 30_000).

Example

iex> delay = ConduitMcp.Client.Backoff.full_jitter(1)
iex> delay in 1..1_000
true