Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
(extend ClosedState CircuitBreakerTransitions
(merge
def-transitions
{:proceed (constantly true)
:on-success
(fn [{f :fail-count p :policy, :as s}]
(if (zero? f) s (ClosedState. p 0)))
:on-error
(fn [{f :fail-count {max-fail :max-fails :as p} :policy, :as s}]
(if (= f max-fail)
(OpenState. p (System/currentTimeMillis))
(assoc s :fail-count (inc f))))}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment