Created
May 5, 2010 07:38
-
-
Save krukow/390494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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