Protocol for circuit breakers guarding operations against cascading failures.
Expected states: :closed - Normal operation; calls proceed normally. :open - Failure threshold breached; calls fail-fast. :half-open - Canary probing / recovery mode (:soft); a limited number of test calls proceed.
Protocol for circuit breakers guarding operations against cascading failures. Expected states: :closed - Normal operation; calls proceed normally. :open - Failure threshold breached; calls fail-fast. :half-open - Canary probing / recovery mode (:soft); a limited number of test calls proceed.
(protect! this f)(protect! this f opts)Executes (f) protected by the circuit breaker.
Opts:
:fallback - (fn [ex]) fallback function called when breaker is :open or (f) fails
:timeout-ms - optional execution timeout in milliseconds
Throws ex-info with {:type :circuit-breaker/open} when the circuit breaker is :open
and no :fallback is provided.
Executes `(f)` protected by the circuit breaker.
Opts:
:fallback - (fn [ex]) fallback function called when breaker is :open or (f) fails
:timeout-ms - optional execution timeout in milliseconds
Throws `ex-info` with `{:type :circuit-breaker/open}` when the circuit breaker is :open
and no :fallback is provided.(reset! this)Manually forces the circuit breaker back to :closed state.
Manually forces the circuit breaker back to `:closed` state.
(state this)Returns current circuit breaker state keyword: :closed, :open, or :half-open.
Returns current circuit breaker state keyword: `:closed`, `:open`, or `:half-open`.
(trip! this)Manually forces the circuit breaker into :open state.
Manually forces the circuit breaker into `:open` state.
(closed? cb)Returns true if the circuit breaker is currently :closed.
Returns true if the circuit breaker is currently :closed.
(half-open? cb)Returns true if the circuit breaker is currently :half-open (probing / soft).
Returns true if the circuit breaker is currently :half-open (probing / soft).
(open? cb)Returns true if the circuit breaker is currently :open.
Returns true if the circuit breaker is currently :open.
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 |