Foundation.CircuitBreaker.Registry (foundation v0.2.1)

Copy Markdown View Source

ETS-based registry for circuit breaker state.

Summary

Functions

Execute a function through a named circuit breaker using the default registry with default options.

Execute a function through a named circuit breaker.

Return the default registry (anonymous ETS table).

Delete a circuit breaker from the registry.

List all circuit breakers and their states.

Create a new registry. Use name: :my_table for a named ETS table.

Reset a circuit breaker to closed state.

Get the current state of a circuit breaker.

Types

registry()

@type registry() :: :ets.tid() | atom()

Functions

call(name, fun)

@spec call(String.t(), (-> result)) :: result | {:error, :circuit_open}
when result: term()

Execute a function through a named circuit breaker using the default registry with default options.

call(registry, name, fun, opts)

@spec call(registry(), String.t(), (-> result), keyword()) ::
  result | {:error, :circuit_open}
when result: term()

Execute a function through a named circuit breaker.

default_registry()

@spec default_registry() :: registry()

Return the default registry (anonymous ETS table).

delete(registry, name)

@spec delete(registry(), String.t()) :: :ok

Delete a circuit breaker from the registry.

list(registry)

List all circuit breakers and their states.

new_registry(opts \\ [])

@spec new_registry(keyword()) :: registry()

Create a new registry. Use name: :my_table for a named ETS table.

reset(registry, name)

@spec reset(registry(), String.t()) :: :ok

Reset a circuit breaker to closed state.

state(registry, name)

Get the current state of a circuit breaker.