Skip to content

Commit ce1c7a8

Browse files
committed
✨ feat(circuitbreaker): add enabled flag to ErrorBreaker
1 parent 1cde32e commit ce1c7a8

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

pkg/risk/circuitbreaker/errorbreaker.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ type ErrorBreaker struct {
4242
mu sync.RWMutex
4343

4444
// breaker configuration
45+
Enabled bool `json:"enabled"`
4546
MaxConsecutiveErrorCount int `json:"maxConsecutiveErrorCount"`
4647
HaltDuration types.Duration `json:"haltDuration"`
4748

@@ -71,6 +72,7 @@ func NewErrorBreaker(strategy, strategyInstance string, maxErrors int, haltDurat
7172
maxErrors = 5
7273
}
7374
b := &ErrorBreaker{
75+
Enabled: true,
7476
MaxConsecutiveErrorCount: maxErrors,
7577
HaltDuration: haltDuration,
7678
errors: make([]ErrorRecord, 0, maxErrors),
@@ -138,6 +140,10 @@ func (b *ErrorBreaker) IsHalted() bool {
138140
b.mu.Lock()
139141
defer b.mu.Unlock()
140142

143+
if !b.Enabled {
144+
return false
145+
}
146+
141147
isHalted := b.isHalted(time.Now())
142148
b.updateMetrics()
143149

0 commit comments

Comments
 (0)