gobreaker compatibility
fluxgo is API-compatible with sony/gobreaker for the common path, so migrating is mostly an import change.
| gobreaker | fluxgo | Note |
|---|---|---|
NewCircuitBreaker(Settings) | NewCircuitBreaker(Settings) | Same signature; panics on an invalid Config |
cb.Execute(req) | cb.Execute(req) | Identical |
cb.State() | cb.State() | Identical |
cb.Counts() | cb.Counts() | Compatible fields |
ErrOpenState | ErrOpenState | Same sentinel error |
ErrTooManyRequests | ErrTooManyRequests | Returned when the Half-Open probe quota is used |
| none | cb.Snapshot() | fluxgo only: observability accessor |
What changes
Section titled “What changes”Settings takes a single Config instead of gobreaker’s ReadyToTrip,
Interval, Timeout and MaxRequests. The trip decision is made by the
adaptive threshold, so there is no callback to write.
gobreaker Settings | fluxgo equivalent |
|---|---|
ReadyToTrip | replaced by the adaptive threshold (ThetaBase, ThetaMin, ThetaMax) |
Timeout | Config.RecoveryTimeout |
MaxRequests | Config.HalfOpenMaxRequests |
Interval | no equivalent: fluxgo uses a rolling window (WindowSize) |
OnStateChange | Settings.OnStateChange (same shape) |
No dependency on gobreaker
Section titled “No dependency on gobreaker”fluxgo does not import gobreaker, so both can live in the same codebase. Wrapping them behind a small interface lets you switch with a flag and compare them on your own traffic, which is how the evaluation is set up.