Circuit-Breaker-for-Scala
Circuit-Breaker-for-Scala copied to clipboard
Guard external service access with a Circuit Breaker based on the book "Release It" (Michael Nygard)
This is a Scala Implementation of the Circuit Breaker state machine mentioned in the book "Release It":http://www.michaelnygard.com/
I used the GoF State Machine pattern (like "Ken DeLong":http://www.jroller.com/kenwdelong/entry/circuit_breaker_in_java), implemented it in Scala and added some factory stuff.
Use it like this
. . . addCircuitBreaker("test", CircuitBreakerConfiguration(100,10)) . . . class Test extends UsingCircuitBreaker { def myMethodWorkingFine = { withCircuitBreaker("test") { . . . } } def myMethodDoingWrong = { withCircuitBreaker("test") { throw new java.lang.IllegalArgumentException } } }
I will add maven pom and addional test specs (see src/TestCircuitBreaker.scala) later.