Skip to main content

Module backoff

Module backoff 

Source
Expand description

Reconnect backoff for lazy transports (#156).

ReconnectBackoff tracks consecutive failed dial attempts and computes an exponential-backoff cooldown window between them. The lazy transports hold one ReconnectBackoff alongside their cached session so failed dials don’t tight-loop on a downed peer — matching the explicit tokio::time::sleep backoff that zmq_connection.rs used to perform.

§Design

  • LazyState bundles the optional cached transport + backoff so they stay consistent under a single lock: “no cached session” always implies “may be in backoff.”
  • invalidate() calls record_failure() so a send-path transport error also counts against the backoff budget (not only dial failures).
  • INITIAL_BACKOFF is 1 s; subsequent failures double up to MAX_BACKOFF (30 s), matching the ZMQ reconnect interval cap observed in practice.

§What #156 defers

DID-doc re-resolve on re-dial (so the manager picks up a moved service entry) requires async resolution which can’t run inside the sync lock; that layer is left for a future incremental PR and documented with a TODO below.

Structs§

LazyState
Combined lazy-connect state: the optional cached transport + reconnect backoff.
ReconnectBackoff
Exponential-backoff cooldown tracker for RPC reconnect attempts.