Releases: 1mb-dev/autobreaker
Release list
v1.1.1 - Critical Architect's Review Fixes (Lint Clean)
AutoBreaker v1.1.1 - Critical Architect's Review Fixes (Lint Clean)
🏛️ Architectural Significance
This release addresses critical production concerns identified during comprehensive architectural review of v1.1.0. The fixes ensure production readiness while maintaining backward compatibility and performance. All linting issues have been resolved.
🔧 Critical Fixes
1. Comprehensive Callback Panic Recovery System
- New File:
panic_recovery.gowith type-safe handlers - Deterministic Behavior:
ReadyToTrippanic → returnsfalse(do not trip - safe default)OnStateChangepanic → logs with state transition context, allows transitionIsSuccessfulpanic → returnsfalse(treat as failure - conservative)
- Thread-Safe Logging: Mutex-protected to prevent race conditions
- Production-Ready: Always compiled (not behind
//go:build !production)
2. Counter Saturation Observability
- Saturation Warnings: Logs when counters reach
math.MaxUint32 - Thread-Safe Operations: CAS loops with saturation protection
- Clear Documentation: Enhanced
Countsstruct documentation
3. Linting Issues Addressed
- ✅ gocritic/paramTypeCombine: Combined consecutive string parameters
- ✅ unparam: Used unused
fromparameter in state transition logging - ✅ unparam: Removed unused
callbackTypeparameter - ✅ Code cleanup: Removed unused
logCallbackPanicfunction - ✅ Simplified API: Cleaner
safeCallWithRecoverysignature
📊 Architectural Review Summary
✅ Production Readiness: Critical edge cases addressed
✅ Thread Safety: Comprehensive concurrency handling
✅ Backward Compatibility: No breaking changes
✅ Observability: Enhanced logging with state context
✅ Code Quality: Linting clean, simplified implementation
✅ Test Coverage: Systematic, phase-based testing
🧪 Testing Verification
- Callback Panic Tests: Comprehensive tests for all callback panic scenarios
- Race Detector Compatibility: Fixed logging to avoid race detector issues
- Performance Maintained: <100ns overhead target preserved
- All Existing Tests Pass: 96.1% coverage maintained
- Linting Clean:
golangci-lintreports 0 issues
📁 Files Changed
internal/breaker/panic_recovery.go: New comprehensive panic recovery system (simplified, lint-clean)internal/breaker/circuitbreaker.go: Updated to use safe callback functionsinternal/breaker/state.go: Updated all callback invocationsinternal/breaker/counts.go: Simplified, uses new safe increment functionsinternal/breaker/types.go: Enhanced saturation documentation- Test files: Updated for new function signatures
🚀 Upgrade Instructions
go get github.com/vnykmshr/autobreaker@v1.1.1No code changes required. This is a drop-in replacement for v1.1.0 with critical fixes.
📈 Performance
- Maintained: <100ns overhead per request in Closed state
- Zero Allocations: No allocations in hot path
- Thread-Safe: Lock-free atomic operations maintained
- Race Detector Clean: Core functionality verified
🔗 Links
- CHANGELOG: Full release notes
- Documentation: GoDoc
- Examples: Examples directory
🙏 Acknowledgments
Thanks to the architectural review that identified these critical production concerns. These fixes make AutoBreaker significantly more reliable for production deployments.
Architect's Recommendation: These fixes address critical production concerns while maintaining performance, compatibility, and code quality. Recommended for all production deployments.
v1.1.0 - Edge Case Hardening & Reliability Improvements
What's New
AutoBreaker v1.1.0 hardens the circuit breaker against edge cases identified in code analysis while maintaining full backward compatibility. This release focuses on reliability improvements for long-running, high-concurrency deployments.
Highlights
🕒 Time Handling Improvements
- Monotonic Clock: Uses
time.Since()instead oftime.Now().UnixNano()subtraction - Negative Duration Prevention: Safeguards against time jumps (NTP adjustments)
- Time Handling Tests: Comprehensive tests for time jump scenarios
🛡️ Callback Safety
- Panic Recovery: User callbacks (
ReadyToTrip,OnStateChange,IsSuccessful) now have panic recovery - Circuit Protection: Callback panics don't break circuit breaker functionality
- Callback Safety Tests: Tests for callback panic scenarios
🔢 Counter Protection
- Counter Saturation: Counters saturate at
math.MaxUint32(4,294,967,295) instead of undefined overflow - Safe Increment/Decrement: Thread-safe CAS loops for atomic counter operations
- Context Cancellation Fix: Fixed request counting when context cancels during execution
- Counter Tests: Tests for counter saturation and long-running scenarios
⚡ State Machine Improvements
- Race Condition Fixes: Improved state transition handling under high concurrency
- Debug Validation: Added validation for state transition invariants
- High-Concurrency Tests: Tests for 1000+ concurrent goroutines
Performance
- Maintained: <100ns overhead per request in Closed state
- Zero Allocations: No allocations in hot path
- Thread-Safe: Lock-free atomic operations maintained
- Race Detector Clean: All tests pass with race detector
Compatibility
- Backward Compatible: No breaking API changes
- All Tests Pass: 95.2% test coverage
- Existing Code: All existing code continues to work unchanged
Files Changed
internal/breaker/state.go: Time handling and state transition improvementsinternal/breaker/counts.go: Counter saturation implementationinternal/breaker/circuitbreaker.go: Callback safety and context fixesinternal/breaker/types.go: Updated documentation- Test files: Comprehensive edge case tests added
- Documentation files: Updated to reflect changes
Testing Evidence
- Comprehensive Tests: Added tests for all identified vulnerabilities
- Race Detector: Clean on all tests
- Stress Tests: Long-running tests for stability verification
- Edge Cases: Tests for time jumps, callback panics, counter saturation
Known Limitations
- Atomic Snapshot Consistency:
Counts()provides point-in-time snapshot but not atomic across all fields - Counter Saturation: Statistics become inaccurate after counters saturate (at 4+ billion requests)
- Documented: All limitations are documented for user awareness
Full Changelog
See CHANGELOG.md for complete details.