Derived from Akka's CircuitBreaker -- minus the Akka dependency with additional enhancements:
- Uses an error percentage threshold over rolling time window to trigger an open state (instead of X number of consecutive failures).
- Option to provide a request volume threshold as a prerequisite for open state.
- A few minor API changes.
import cb.CircuitBreaker.Configs
import scala.concurrent.Future
val cb = CircuitBreaker("cb", Configs(...))
cb.withCircuitBreaker {
Future {
// external call to db, 3rd party service, etc..
}
}