Created
May 5, 2010 08:27
-
-
Save krukow/390535 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
(def cb (make-circuit-breaker)) | |
(def succ (wrap-with (constantly 42) cb)) | |
(def fail (wrap-with (fn [] (throw (Exception.))) cb)) | |
(dotimes [i 5] | |
(try (fail) (catch Exception e))) | |
(assert (= (ClosedState. default-policy 5) @cb)) | |
(try (fail) (catch Exception e)) | |
(assert (= (class (OpenState. default-policy 0)) (class @cb))) | |
(Thread/sleep 5000) | |
(succ) | |
(assert (= (ClosedState. default-policy 0) @cb)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment