PushX.ReconnectGuard (PushX v0.15.0)

Copy Markdown View Source

Coalesces HTTP pool reconnects so concurrent failures cause one restart.

Restarting a Finch pool kills every in-flight connection it holds. When many concurrent sends observe a connection error at the same time (e.g. a network blip during a large push_batch), each of them requesting a pool restart turns a brief blip into a self-amplifying outage: every restart fails other in-flight requests, which then request more restarts.

This process grants at most one reconnect per pool per cooldown window. The default window is 5000 ms; configure with:

config :pushx, reconnect_cooldown_ms: 5_000

Manual calls to PushX.reconnect/0 are not gated — only the automatic reconnects issued by PushX.Retry go through this guard.

Summary

Functions

Returns true if the caller should perform the reconnect for key.

Returns a specification to start this module under a supervisor.

Functions

acquire(key)

@spec acquire(term()) :: boolean()

Returns true if the caller should perform the reconnect for key.

At most one caller per key is granted true within each cooldown window; the rest get false and should skip (a restart just happened or is underway). key is :default for the shared static pool, or the instance name for PushX.Instance pools.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])