semian icon indicating copy to clipboard operation
semian copied to clipboard

dual circuit breaker implementation for switching between adaptive and classic modes

Open adriangudas opened this issue 2 months ago • 2 comments

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.

adriangudas avatar Oct 21 '25 17:10 adriangudas

OK. I think I made some changes based on that pattern that will allow us to avoid using the full adapter pattern. Basically:

  1. Create a class method, here, that can be used to set the selector using Semian::DualCircuitBreaker.adaptive_circuit_breaker_selector(proc)
  2. 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

adriangudas avatar Dec 01 '25 20:12 adriangudas

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 🤔

adriangudas avatar Dec 02 '25 14:12 adriangudas