feat: Add ResetCircuitBreaker helper
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user