@@ -26,20 +26,19 @@ import (
26
26
"github.com/pkg/errors"
27
27
)
28
28
29
+ // Circuit Breaker State Machine:
29
30
//
30
- // Circuit Breaker State Machine:
31
- //
32
- // switch to open based on rule
33
- // +-----------------------------------------------------------------------+
34
- // | |
35
- // | v
36
- // +----------------+ +----------------+ Probe +----------------+
37
- // | | | |<----------------| |
38
- // | | Probe succeed | | | |
39
- // | Closed |<------------------| HalfOpen | | Open |
40
- // | | | | Probe failed | |
41
- // | | | +---------------->| |
42
- // +----------------+ +----------------+ +----------------+
31
+ // switch to open based on rule
32
+ // +-----------------------------------------------------------------------+
33
+ // | |
34
+ // | v
35
+ // +----------------+ +----------------+ Probe +----------------+
36
+ // | | | |<----------------| |
37
+ // | | Probe succeed | | | |
38
+ // | Closed |<------------------| HalfOpen | | Open |
39
+ // | | | | Probe failed | |
40
+ // | | | +---------------->| |
41
+ // +----------------+ +----------------+ +----------------+
43
42
type State int32
44
43
45
44
const (
@@ -126,7 +125,7 @@ type CircuitBreaker interface {
126
125
OnRequestComplete (rtt uint64 , err error )
127
126
}
128
127
129
- //================================= circuitBreakerBase ====================================
128
+ // ================================= circuitBreakerBase ====================================
130
129
// circuitBreakerBase encompasses the common fields of circuit breaker.
131
130
type circuitBreakerBase struct {
132
131
rule * Rule
@@ -230,7 +229,7 @@ func (b *circuitBreakerBase) fromHalfOpenToOpen(snapshot interface{}) bool {
230
229
return false
231
230
}
232
231
233
- // fromHalfOpenToOpen updates circuit breaker state machine from half-open to closed
232
+ // fromHalfOpenToClosed updates circuit breaker state machine from half-open to closed
234
233
// Return true only if current goroutine successfully accomplished the transformation.
235
234
func (b * circuitBreakerBase ) fromHalfOpenToClosed () bool {
236
235
if b .state .cas (HalfOpen , Closed ) {
@@ -245,7 +244,7 @@ func (b *circuitBreakerBase) fromHalfOpenToClosed() bool {
245
244
return false
246
245
}
247
246
248
- //================================= slowRtCircuitBreaker ====================================
247
+ // ================================= slowRtCircuitBreaker ====================================
249
248
type slowRtCircuitBreaker struct {
250
249
circuitBreakerBase
251
250
stat * slowRequestLeapArray
@@ -437,7 +436,7 @@ func (s *slowRequestLeapArray) allCounter() []*slowRequestCounter {
437
436
return ret
438
437
}
439
438
440
- //================================= errorRatioCircuitBreaker ====================================
439
+ // ================================= errorRatioCircuitBreaker ====================================
441
440
type errorRatioCircuitBreaker struct {
442
441
circuitBreakerBase
443
442
minRequestAmount uint64
@@ -622,7 +621,7 @@ func (s *errorCounterLeapArray) allCounter() []*errorCounter {
622
621
return ret
623
622
}
624
623
625
- //================================= errorCountCircuitBreaker ====================================
624
+ // ================================= errorCountCircuitBreaker ====================================
626
625
type errorCountCircuitBreaker struct {
627
626
circuitBreakerBase
628
627
minRequestAmount uint64
0 commit comments