A Go library implementing the Circuit Breaker pattern to handle remote call failures and prevent resource exhaustion.
circuitbreaker is a Go library that implements the Circuit Breaker pattern to protect applications making remote calls. It prevents resource exhaustion when remote calls hang or fail by tripping after defined failures and temporarily blocking further calls. The library provides multiple breaker types, timeout wrapping, and an HTTP client wrapper for building fault-tolerant distributed systems.
Go developers building distributed systems or microservices that make remote calls to external services, APIs, or databases. It is particularly useful for engineers needing to prevent cascading failures and manage fault tolerance in high-volume applications.
Developers choose circuitbreaker for its simplicity, reliability, and comprehensive feature set including multiple breaker strategies (threshold, consecutive, rate), manual control, and built-in HTTP client support. It follows established patterns from Martin Fowler and Netflix, making it a trusted solution for implementing circuit breaking in Go applications.
Circuit Breakers in Go
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Offers threshold, consecutive, and rate-based breakers, providing flexibility in failure detection, as shown in examples for NewThresholdBreaker, NewConsecutiveBreaker, and NewRateBreaker.
Includes a specialized HTTP client wrapper with circuit breaking and timeouts, simplifying protection for web requests, demonstrated in the NewHTTPClient example.
Allows manual trip/reset handling and subscription to events like BreakerTripped for observability, as described in the manual control and event monitoring sections.
Automatically wraps remote calls with configurable timeouts to prevent hangs, which count as failures, illustrated in the Call method with a timeout parameter.
Lacks integrated retry logic, forcing developers to implement retries separately for comprehensive fault tolerance, unlike some alternatives like hystrix-go.
Monitoring events requires manual goroutine and channel management, as shown in the subscription example, adding complexity to codebases.
Misses support for adaptive breaking based on latency or seamless metrics integration, which might be needed for sophisticated distributed systems.