Skip to content

gobreaker compatibility

fluxgo is API-compatible with sony/gobreaker for the common path, so migrating is mostly an import change.

gobreakerfluxgoNote
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
ErrOpenStateErrOpenStateSame sentinel error
ErrTooManyRequestsErrTooManyRequestsReturned when the Half-Open probe quota is used
nonecb.Snapshot()fluxgo only: observability accessor

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 Settingsfluxgo equivalent
ReadyToTripreplaced by the adaptive threshold (ThetaBase, ThetaMin, ThetaMax)
TimeoutConfig.RecoveryTimeout
MaxRequestsConfig.HalfOpenMaxRequests
Intervalno equivalent: fluxgo uses a rolling window (WindowSize)
OnStateChangeSettings.OnStateChange (same shape)

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.