@@ -26,20 +26,19 @@ import (
2626 "github.com/pkg/errors"
2727)
2828
29+ // Circuit Breaker State Machine:
2930//
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+ // +----------------+ +----------------+ +----------------+
4342type State int32
4443
4544const (
@@ -126,7 +125,7 @@ type CircuitBreaker interface {
126125 OnRequestComplete (rtt uint64 , err error )
127126}
128127
129- //================================= circuitBreakerBase ====================================
128+ // ================================= circuitBreakerBase ====================================
130129// circuitBreakerBase encompasses the common fields of circuit breaker.
131130type circuitBreakerBase struct {
132131 rule * Rule
@@ -230,7 +229,7 @@ func (b *circuitBreakerBase) fromHalfOpenToOpen(snapshot interface{}) bool {
230229 return false
231230}
232231
233- // fromHalfOpenToOpen updates circuit breaker state machine from half-open to closed
232+ // fromHalfOpenToClosed updates circuit breaker state machine from half-open to closed
234233// Return true only if current goroutine successfully accomplished the transformation.
235234func (b * circuitBreakerBase ) fromHalfOpenToClosed () bool {
236235 if b .state .cas (HalfOpen , Closed ) {
@@ -245,7 +244,7 @@ func (b *circuitBreakerBase) fromHalfOpenToClosed() bool {
245244 return false
246245}
247246
248- //================================= slowRtCircuitBreaker ====================================
247+ // ================================= slowRtCircuitBreaker ====================================
249248type slowRtCircuitBreaker struct {
250249 circuitBreakerBase
251250 stat * slowRequestLeapArray
@@ -437,7 +436,7 @@ func (s *slowRequestLeapArray) allCounter() []*slowRequestCounter {
437436 return ret
438437}
439438
440- //================================= errorRatioCircuitBreaker ====================================
439+ // ================================= errorRatioCircuitBreaker ====================================
441440type errorRatioCircuitBreaker struct {
442441 circuitBreakerBase
443442 minRequestAmount uint64
@@ -622,7 +621,7 @@ func (s *errorCounterLeapArray) allCounter() []*errorCounter {
622621 return ret
623622}
624623
625- //================================= errorCountCircuitBreaker ====================================
624+ // ================================= errorCountCircuitBreaker ====================================
626625type errorCountCircuitBreaker struct {
627626 circuitBreakerBase
628627 minRequestAmount uint64
0 commit comments