Skip to content

go.missing_circuit_breaker

Stability High

Detects HTTP client calls to external services without circuit breaker protection, which can cause cascading failures.

Without circuit breakers:

  • Cascading failures — One slow service brings down everything
  • Resource exhaustion — Goroutines pile up waiting for responses
  • Extended outages — Failing service never gets time to recover
  • Poor user experience — All requests slow down, not just affected ones
// ❌ Before (no circuit breaker)
func fetchData(url string) ([]byte, error) {
resp, err := http.Get(url)
if err != nil {
return nil, err
}
return io.ReadAll(resp.Body)
}
// ✅ After (with circuit breaker)
import "github.com/sony/gobreaker"
var cb = gobreaker.NewCircuitBreaker(gobreaker.Settings{
Name: "api",
MaxRequests: 5,
Interval: 10 * time.Second,
Timeout: 30 * time.Second,
ReadyToTrip: func(counts gobreaker.Counts) bool {
return counts.ConsecutiveFailures > 5
},
})
func fetchData(url string) ([]byte, error) {
result, err := cb.Execute(func() (interface{}, error) {
resp, err := http.Get(url)
if err != nil {
return nil, err
}
return io.ReadAll(resp.Body)
})
if err != nil {
return nil, err
}
return result.([]byte), nil
}
  • HTTP calls without circuit breaker wrapper
  • gRPC client calls without breakers
  • External service integrations without failure isolation
  • Database connections without circuit protection

Unfault generates patches using github.com/sony/gobreaker:

import "github.com/sony/gobreaker"
var circuitBreaker = gobreaker.NewCircuitBreaker(gobreaker.Settings{
Name: "external-api",
MaxRequests: 3,
Timeout: 60 * time.Second,
})