ExMCP.Reliability.CircuitBreaker (ex_mcp v0.10.0)

View Source

Circuit breaker GenServer wrapper for ExMCP.Transport.Beam.CircuitBreaker.

Provides a GenServer-based interface to the circuit breaker pattern for protecting MCP services from cascading failures.

Summary

Functions

Executes a function through the circuit breaker.

Executes a function through the circuit breaker with timeout.

Returns a specification to start this module under a supervisor.

Manually closes the circuit breaker.

Gets the current state of the circuit breaker.

Gets circuit breaker statistics.

Manually opens the circuit breaker.

Resets the circuit breaker to initial state.

Starts a circuit breaker process.

Manually trips (opens) the circuit breaker. Alias for open/1 to match test expectations.

Types

options()

@type options() :: [
  failure_threshold: non_neg_integer(),
  success_threshold: non_neg_integer(),
  timeout: non_neg_integer(),
  reset_timeout: non_neg_integer(),
  error_filter: (any() -> boolean())
]

Functions

call(server, fun)

@spec call(GenServer.server(), (-> any())) :: any()

Executes a function through the circuit breaker.

call(server, fun, timeout)

@spec call(GenServer.server(), (-> any()), timeout()) :: any()

Executes a function through the circuit breaker with timeout.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

close(server)

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

Manually closes the circuit breaker.

get_state(server)

Gets the current state of the circuit breaker.

get_stats(server)

@spec get_stats(GenServer.server()) :: map()

Gets circuit breaker statistics.

open(server)

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

Manually opens the circuit breaker.

reset(server)

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

Resets the circuit breaker to initial state.

start_link(opts \\ [])

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

Starts a circuit breaker process.

trip(server)

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

Manually trips (opens) the circuit breaker. Alias for open/1 to match test expectations.