File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -101,17 +101,18 @@ func (cb *CircuitBreaker) Execute(fn func() error) error {
101
101
if cb .state .CompareAndSwap (int32 (CircuitBreakerOpen ), int32 (CircuitBreakerHalfOpen )) {
102
102
cb .requests .Store (0 )
103
103
cb .successes .Store (0 )
104
- state = CircuitBreakerHalfOpen // Update local state
105
104
if cb .config != nil && cb .config .LogLevel .InfoOrAbove () {
106
105
internal .Logger .Printf (context .Background (),
107
106
"hitless: circuit breaker for %s transitioning to half-open" , cb .endpoint )
108
107
}
108
+ // Fall through to half-open logic
109
109
} else {
110
110
return ErrCircuitBreakerOpen
111
111
}
112
112
} else {
113
113
return ErrCircuitBreakerOpen
114
114
}
115
+ fallthrough
115
116
case CircuitBreakerHalfOpen :
116
117
requests := cb .requests .Add (1 )
117
118
if requests > int64 (cb .maxRequests ) {
@@ -168,10 +169,11 @@ func (cb *CircuitBreaker) recordSuccess() {
168
169
169
170
state := CircuitBreakerState (cb .state .Load ())
170
171
171
- if state == CircuitBreakerClosed {
172
+ switch state {
173
+ case CircuitBreakerClosed :
172
174
// Reset failure count on success in closed state
173
175
cb .failures .Store (0 )
174
- } else if state == CircuitBreakerHalfOpen {
176
+ case CircuitBreakerHalfOpen :
175
177
successes := cb .successes .Add (1 )
176
178
177
179
// If we've had enough successful requests, close the circuit
You can’t perform that action at this time.
0 commit comments