Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@krukow
Created May 5, 2010 07:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krukow/390494 to your computer and use it in GitHub Desktop.
Save krukow/390494 to your computer and use it in GitHub Desktop.
(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