(create opts)Create a Circuit Breaker instance. opts: :failure-threshold — consecutive failure count threshold (default: 5) :reset-timeout-ms — wait time in ms before open -> half-open (default: 10000) :half-open-calls — successes needed in half-open to close (default: 1) :failure? — return-value-based failure predicate (default: (constantly false)) :on-state-change — (fn [old-status new-status]) state transition callback
Create a Circuit Breaker instance. opts: :failure-threshold — consecutive failure count threshold (default: 5) :reset-timeout-ms — wait time in ms before open -> half-open (default: 10000) :half-open-calls — successes needed in half-open to close (default: 1) :failure? — return-value-based failure predicate (default: (constantly false)) :on-state-change — (fn [old-status new-status]) state transition callback
(reset! breaker)Manually reset the Circuit Breaker to :closed.
Manually reset the Circuit Breaker to :closed.
(shutdown! breaker)Stop the go-loop and release resources. Idempotent.
Stop the go-loop and release resources. Idempotent.
(status breaker)Return the current Circuit Breaker state: :closed | :open | :half-open
Return the current Circuit Breaker state: :closed | :open | :half-open
(wrap breaker f)Wrap function f with the Circuit Breaker.
Wrap function f with the Circuit Breaker.
- :closed / :half-open: executes f, records success/failure
- :open: skips f, returns {:resilience/rejected :circuit-open}
Exceptions are re-thrown after being counted as failures.cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |