ETS-backed store for circuit breaker state.
One entry per fuse name:
{fuse_name, state, failure_window, opened_at}Where:
stateis:closed | {:open, monotonic_ms} | :half_openfailure_windowis a list of{monotonic_ms, :failure}tuples used to count failures within the sliding time window.
The process owns the table so it survives crashes of consumers.
Summary
Functions
Returns a snapshot of all fuse states (useful for health checks).
Returns a specification to start this module under a supervisor.
Records a failure within the sliding window. Returns the current failure count within the window.
Records a success — clears the failure window.
Resets all fuses to CLOSED. Useful in tests.
Resets the breaker to CLOSED.
Transitions to HALF_OPEN for probe.
Trips the breaker to OPEN.
Returns the current state for the given fuse: :closed | {:open, ms} | :half_open
Functions
Returns a snapshot of all fuse states (useful for health checks).
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec record_failure(term(), pos_integer()) :: non_neg_integer()
Records a failure within the sliding window. Returns the current failure count within the window.
@spec record_success(term()) :: :ok
Records a success — clears the failure window.
@spec reset_all() :: :ok
Resets all fuses to CLOSED. Useful in tests.
@spec set_closed(term()) :: :ok
Resets the breaker to CLOSED.
@spec set_half_open(term()) :: :ok
Transitions to HALF_OPEN for probe.
@spec set_open(term()) :: :ok
Trips the breaker to OPEN.
@spec start_link(keyword()) :: GenServer.on_start()
Returns the current state for the given fuse: :closed | {:open, ms} | :half_open