akka/akka — pull request #427 by scullxbones (2012-04-28 19:12:18+00:00)
Title: Add circuit breaker facility to DurableMailboxQueue base class for use b...

...y subclasses. Circuit breaker implementation as described by Michael T. Nygard in Release It!. Fixes #1734

* Create finite state machine for three states: Closed, Open, Half-Open
* Closed state allows calls through, and on sequential failures exceeding the max# set - transitions to Open state. Intervening successes cause the failure count to reset to 0
* Open state throws a CircuitOpenException on every call until the reset timeout is reached which causes a transition to Half-Open state
* Half-Open state will allow the next single call through, if it succeeds - transition to Closed state, if it fails - transition back to Open state, starting the reset timer again
* Allow configuration for the call and reset timeouts, as well as the maximum number of sequential failures before opening
* Failures can be either thrown exceptions or call timeouts (internally throws an exception)
* Uses akka scheduler for timer events

As you can see, this is not fully integrated yet, would like some feedback before injecting it into mongo, redis, etc. At this point it only adds the facility to the base class. I tried to write it in such a way that it could be extracted as a utility and used elsewhere if appropriate.

Thanks for your time!