diff --git a/plugin/circuitbreaker/composite/counter.go b/plugin/circuitbreaker/composite/counter.go index 4cbc0dcc..0d02db00 100644 --- a/plugin/circuitbreaker/composite/counter.go +++ b/plugin/circuitbreaker/composite/counter.go @@ -192,6 +192,10 @@ func (rc *ResourceCounters) HalfOpenToClose() { rc.log.Infof("previous status %s, current status %s, resource %s, rule %s", status.GetStatus(), newStatus.GetStatus(), rc.resource.String(), status.GetCircuitBreaker()) rc.reportCircuitStatus(newStatus) + + for _, counter := range rc.counters { + counter.Resume() + } } func (rc *ResourceCounters) HalfOpenToOpen() { diff --git a/plugin/circuitbreaker/composite/trigger/consecutive.go b/plugin/circuitbreaker/composite/trigger/consecutive.go index 9225763d..67d2a9e9 100644 --- a/plugin/circuitbreaker/composite/trigger/consecutive.go +++ b/plugin/circuitbreaker/composite/trigger/consecutive.go @@ -55,3 +55,9 @@ func (c *ConsecutiveCounter) Report(success bool) { atomic.StoreInt32(&c.consecutiveErrors, 0) } } + +func (c *ConsecutiveCounter) Resume() { + if c.isSuspend() { + c.resume() + } +} diff --git a/plugin/circuitbreaker/composite/trigger/counter.go b/plugin/circuitbreaker/composite/trigger/counter.go index ccab4d93..67d68226 100644 --- a/plugin/circuitbreaker/composite/trigger/counter.go +++ b/plugin/circuitbreaker/composite/trigger/counter.go @@ -52,6 +52,8 @@ type Options struct { type TriggerCounter interface { // Report . Report(success bool) + // Resume . + Resume() } func newBaseCounter(rule string, opt *Options) *baseCounter { diff --git a/plugin/circuitbreaker/composite/trigger/err_rate.go b/plugin/circuitbreaker/composite/trigger/err_rate.go index b1257fec..a727799f 100644 --- a/plugin/circuitbreaker/composite/trigger/err_rate.go +++ b/plugin/circuitbreaker/composite/trigger/err_rate.go @@ -124,6 +124,12 @@ func (c *ErrRateCounter) Report(success bool) { } } +func (c *ErrRateCounter) Resume() { + if c.isSuspend() { + c.resume() + } +} + func getBucketInterval(interval time.Duration) time.Duration { bucketSize := math.Ceil(float64(interval) / float64(bucketCount)) return time.Duration(bucketSize)