mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 16:01:55 +03:00
Add tests for circuit breaker
This commit is contained in:
@@ -71,7 +71,7 @@ func (c *circuitBreakerDialer) doClosed(ctx context.Context,
|
||||
|
||||
c.failuresCount++
|
||||
|
||||
if c.state == circuitBreakerStateClosed && c.failuresCount > c.openThreshold {
|
||||
if c.state == circuitBreakerStateClosed && c.failuresCount >= c.openThreshold {
|
||||
c.switchState(circuitBreakerStateOpened)
|
||||
}
|
||||
|
||||
@@ -184,6 +184,7 @@ func newCircuitBreakerDialer(baseDialer Dialer,
|
||||
openThreshold uint32, halfOpenTimeout, resetFailuresTimeout time.Duration) Dialer {
|
||||
cb := &circuitBreakerDialer{
|
||||
Dialer: baseDialer,
|
||||
stateMutexChan: make(chan bool, 1),
|
||||
openThreshold: openThreshold,
|
||||
halfOpenTimeout: halfOpenTimeout,
|
||||
resetFailuresTimeout: resetFailuresTimeout,
|
||||
|
||||
Reference in New Issue
Block a user