# `PhoenixGenApi.WorkerPool.CircuitBreaker`
[🔗](https://github.com/ohhi-vn/phoenix_gen_api/blob/main/lib/phoenix_gen_api/worker_pool/circuit_breaker.ex#L1)

Shared circuit breaker functions for WorkerPool and Worker.

This module provides common circuit breaker logic to avoid
code duplication between the pool-level and worker-level
circuit breakers.

# `circuit_open?`

Checks if the circuit breaker is open (in cooldown period).

Returns `true` if the circuit breaker is open (rejecting requests),
`false` if requests should be allowed.

## Parameters

- `circuit_open_at`: The monotonic time (in milliseconds) when the circuit
  was opened, or `nil` if the circuit is closed.
- `cooldown_ms`: The cooldown period in milliseconds.

## Examples

    iex> CircuitBreaker.circuit_open?(nil, 5000)
    false

    iex> now = System.monotonic_time(:millisecond)
    iex> CircuitBreaker.circuit_open?(now, 5000)
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
