Getting Started with AutoBreaker#
AutoBreaker is an adaptive circuit breaker for Go that uses percentage-based thresholds to automatically adjust to traffic patterns.
Why AutoBreaker?#
Traditional circuit breakers use static failure thresholds (e.g., “trip after 10 failures”). This creates problems:
- High traffic: 10 failures may represent <1% error rate (too sensitive)
- Low traffic: 10 failures may be 100% error rate (too slow to protect)
AutoBreaker uses percentage-based thresholds that adapt to request volume automatically. Configure once, works correctly across all traffic levels.
Installation#
| |
Requires Go 1.21 or later.
Quick Start#
| |
How It Works#
AutoBreaker calculates failure rate as a percentage of recent requests:
| |
Key Features#
- Adaptive Thresholds - Percentage-based failure detection scales with traffic
- Runtime Configuration - Update settings without restart
- Zero Dependencies - Standard library only
- High Performance - <100ns overhead per request, zero allocations
- Observability - Metrics() and Diagnostics() APIs built-in
- Thread-Safe - Lock-free atomic operations throughout
Next Steps#
- Configuration - Detailed settings and options
- Examples - Production-ready code examples
- API Reference - Complete API documentation
- Migration Guide - Moving from sony/gobreaker
Configuration#
For detailed configuration options and advanced settings, see the Configuration Guide.
Examples#
Production-ready code examples are available in the examples directory on GitHub.