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.
Summary
Functions
Checks if the circuit breaker is open (in cooldown period).
Functions
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, ornilif 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