Closed RobWin closed 8 years ago
I think I refactor this again. The CircuitBreaker should not store exceptions itself, but publish events as a event stream. An event can be an exception (CircuitBreakerRecordedFailureEvent
) or a state transition (CircuitBreakerStateTransitionEvent
).
A system which is interested in these events can subscribe to the event stream and store the events in a CircularBuffer itself. The CircuitBreaker is lightweight again, but extendable by using reative streams. I think I introduce RxJava to make the CircuitBreaker an Publisher
. That way I don't have to implement an EventBus myself.
Using Reactive Streams the events can easily be handled on a different thread pool and do not decrease the performance of the CircuitBreaker.
Hi @RobWin Please consider usage of ReactiveStreams specification. With this interfaces the implementation will be meter of choice for library users [RxJava, Akka, Reactor...]. It also will be compatible with Java9's Flow
Yes, I will just add org.reactivestreams:reactive-streams:1.0.0
as a compile dependency
A CircuitBreaker should store (a configurage number of) handled exceptions so that you can retrieve the list of exceptions which have triggered the CB. This helps in cases where you have to analyze some error.