Parrhesia.Storage.Adapters.Postgres.Circuit (parrhesia v0.12.0)

Copy Markdown

Lightweight fast-fail guard for PostgreSQL connectivity incidents.

The guard opens after consecutive connection failures and temporarily rejects new DB-backed operations with {:error, :storage_unavailable}.

Summary

Types

run_opt()

@type run_opt() :: {:server, GenServer.server()} | {:fallback_error, term()}

Functions

allow(server \\ __MODULE__)

@spec allow(GenServer.server()) :: :ok | {:error, :storage_unavailable}

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

mark_failure(server \\ __MODULE__)

@spec mark_failure(GenServer.server()) :: :ok

mark_success(server \\ __MODULE__)

@spec mark_success(GenServer.server()) :: :ok

run(fun, opts \\ [])

@spec run((-> term()), [run_opt()]) :: term()

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()