dual circuit breaker implementation for switching between adaptive and classic modes
A basic implementation of a DualCircuitBreaker interface that allows us to check a lambda every time we enter acquire, and hand off the request to either the classic circuit breaker, or the adaptive circuit breaker, for processing (both are initialized at application start). The lambda has to return true (use adaptive) or false (use legacy) and provides a pluggable interface to other applications to define the lambda outside of the semian codebase itself, and set it at runtime.
OK. I think I made some changes based on that pattern that will allow us to avoid using the full adapter pattern. Basically:
- Create a class method, here, that can be used to set the selector using
Semian::DualCircuitBreaker.adaptive_circuit_breaker_selector(proc) - Write a function that looks up the appropriate value from our dynamic config and returns true or false, and assign it to that proc in the application code
Also wondering if we need to call reset to clear the circuit breaker state (i.e. close all circuits) when we switch back and forth 🤔