(current {cb :com.potetm.fusebox.cljs.circuit-breaker/circuit-breaker})
The current circuit breaker state. Useful for diagnostics or testing.
The current circuit breaker state. Useful for diagnostics or testing.
(fail-pct r)
The percent of calls currently tracked by the circuit breaker which are failed.
The percent of calls currently tracked by the circuit breaker which are failed.
(init {_ns :com.potetm.fusebox.cljs.circuit-breaker/next-state
hs :com.potetm.fusebox.cljs.circuit-breaker/hist-size
_hot :com.potetm.fusebox.cljs.circuit-breaker/half-open-tries
_scm :com.potetm.fusebox.cljs.circuit-breaker/slow-call-ms
succ? :com.potetm.fusebox.cljs.circuit-breaker/success?
:as spec})
Initialize a circuit breaker.
spec is a map containing: ::next-state - fn taking the current circuit breaker and returning the next state or nil if no transition is necessary. See next-state:default for a default implementation. Return value must be one of: ::closed, ::half-opened, ::opened ::hist-size - The number of calls to track ::half-open-tries - The number of calls to allow in a ::half-open state ::slow-call-ms - Milli threshold to label a call slow ::success? - A function which takes a return value and determines whether it was successful. If false, a ::failure is recorded.
Initialize a circuit breaker. spec is a map containing: ::next-state - fn taking the current circuit breaker and returning the next state or nil if no transition is necessary. See next-state:default for a default implementation. Return value must be one of: ::closed, ::half-opened, ::opened ::hist-size - The number of calls to track ::half-open-tries - The number of calls to allow in a ::half-open state ::slow-call-ms - Milli threshold to label a call slow ::success? - A function which takes a return value and determines whether it was successful. If false, a ::failure is recorded.
(next-state:default opts r)
A default ::next-state implementation.
A default ::next-state implementation. * :fail-pct - The decimal threshold to use to open the breaker due to failed calls (0, 1] * :slow-pct - The decimal threshold to use to open the breaker due to slow calls (0, 1] * :wait-for-count - The number of calls to wait for after transitioning before transitioning again * :open->half-open-after-ms - Millis to wait before transitioning from ::opened to ::half-opened
(should-close? r wait-for fail-threshold slow-threshold)
Default implementation for determining whether to transition to a ::closed state.
Default implementation for determining whether to transition to a ::closed state.
(should-open? r wait-for fail-threshold slow-threshold)
Default implementation for determining whether to transition to a ::opened state.
Default implementation for determining whether to transition to a ::opened state.
(slow-pct r)
The percent of calls currently tracked by the circuit breaker which are slow.
The percent of calls currently tracked by the circuit breaker which are slow.
(slow|fail-pct r)
The percent of calls currently tracked by the circuit breaker which are either slow or failed.
The percent of calls currently tracked by the circuit breaker which are either slow or failed.
(time-expired? r duration-ms)
Has the provided duration-ms (in millis) expired since the last state transition for this circuit breaker?
Has the provided duration-ms (in millis) expired since the last state transition for this circuit breaker?
(with-circuit-breaker spec & body)
Evaluates body which returns a promise, guarded by the provided circuit breaker.
Evaluates body which returns a promise, guarded by the provided circuit breaker.
(with-circuit-breaker*
{cb :com.potetm.fusebox.cljs.circuit-breaker/circuit-breaker
succ? :com.potetm.fusebox.cljs.circuit-breaker/success?
:as spec}
f)
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close