LLMUtils.CircuitBreaker (llm_utils v0.1.3)

Copy Markdown View Source

In-memory ETS-based 3-state circuit breaker.

States: closed → open → half-open → closed

  • Closed: Normal operation, requests pass through
  • Open: Failing, requests are rejected immediately
  • Half-open: Testing if service recovered

Usage

LLMUtils.CircuitBreaker.call(:my_service, fn -> my_request() end)

Override by passing a module implementing call/3 in Client options.

Summary

Functions

Execute a function with circuit breaking.

Functions

call(name, fun, opts \\ [])

@spec call(atom(), function(), keyword()) :: {:ok, any()} | {:error, term()}

Execute a function with circuit breaking.

Parameters

  • name — Circuit identifier (atom)
  • fun — Zero-arity function to execute
  • opts — Options (failure_threshold, cooldown_ms)