livery_client_circuit_store (livery v0.2.0)

View Source

Owns the ETS table backing the client circuit breakers.

A gen_server that creates a public named table at startup and clears it on shutdown; the decision logic in livery_client_circuit reads and writes the table directly (no per-request round trip through this process). One row per breaker name: {Name, Status, Fails, Total, OpenedAtMs} where Status is closed | open | half_open.

Summary

Functions

May a request pass? Half-opens an expired-cooldown breaker to probe.

Record a request outcome and update the breaker state.

Forget a breaker's state.

Types

state()

-type state() :: #state{}.

Functions

allow(Name, Cooldown)

-spec allow(term(), non_neg_integer()) -> allow | deny.

May a request pass? Half-opens an expired-cooldown breaker to probe.

handle_call(Request, From, State)

-spec handle_call(term(), {pid(), term()}, state()) -> {reply, ok, state()}.

handle_cast(Msg, State)

-spec handle_cast(term(), state()) -> {noreply, state()}.

handle_info(Info, State)

-spec handle_info(term(), state()) -> {noreply, state()}.

init/1

-spec init([]) -> {ok, state()}.

record(Name, Outcome, Window, Trip)

-spec record(term(), ok | err, pos_integer(), float()) -> ok.

Record a request outcome and update the breaker state.

reset(Name)

-spec reset(term()) -> ok.

Forget a breaker's state.

start_link()

-spec start_link() -> {ok, pid()} | {error, term()}.