gobreaker is a circuit breaker implementation in Go that prevents requests from being sent when they are likely to fail.
The tool addresses the problem of cascading failures in distributed systems by implementing the circuit breaker pattern as a state machine. It wraps function calls and monitors their success or failure, transitioning between closed, open, and half-open states. When failures exceed a threshold, the circuit breaker opens to reject requests immediately rather than allowing them to fail. After a timeout period, it enters a half-open state to test whether the underlying service has recovered before resuming normal operation.
Developers building microservices or systems that call external services should consider this tool when they need resilience against transient failures. The implementation is particularly suited for Go applications where you want to prevent cascading failures without external dependencies. The tool offers fine-grained configuration through its Settings struct, allowing you to customize the failure threshold via the ReadyToTrip callback, define state transition behavior with OnStateChange, and distinguish between errors that should affect the circuit breaker state and those that should be ignored through the IsExcluded callback. It supports both fixed and rolling window strategies for tracking request counts, with the rolling window approach providing more granular failure detection over time.
The project maintains a steady stream of commits addressing bug fixes and feature enhancements. Pull requests are regularly reviewed and merged, indicating active maintenance. Issues are addressed with responsive feedback from maintainers. The codebase receives updates that refine the circuit breaker logic and expand configuration options based on user needs.