feat: Add ResetCircuitBreaker helper

This commit is contained in:
2026-08-16 03:41:26 +03:00
parent 26c4be2d3a
commit 286cb8653a
4 changed files with 70 additions and 6 deletions

View File

@@ -319,6 +319,19 @@ func newCircuitBreaker() *circuitBreaker {
}
}
// ResetCircuitBreaker resets the circuit breaker to its initial closed state.
// This is useful for testing or recovery scenarios where the circuit needs to be
// manually reset without waiting for the timeout.
func (cb *circuitBreaker) ResetCircuitBreaker() {
cb.mu.Lock()
defer cb.mu.Unlock()
cb.state = closed
cb.failures = 0
cb.successes = 0
cb.openSince = time.Time{}
}
func (cb *circuitBreaker) allow() bool {
cb.mu.Lock()
defer cb.mu.Unlock()