File tree Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Expand file tree Collapse file tree 3 files changed +14
-2
lines changed Original file line number Diff line number Diff line change 13
13
14
14
/go.work *
15
15
16
- * .bench
16
+ * .bench
17
+
18
+ .idea /
Original file line number Diff line number Diff line change @@ -129,6 +129,11 @@ func (e *EWMABreaker) apply(o *options) error {
129
129
if o .halfOpenDelay == 0 {
130
130
return fmt .Errorf ("EWMABreaker requires a half-open delay" )
131
131
}
132
+
133
+ if e .threshold < 0 || e .threshold > 1 {
134
+ return fmt .Errorf ("EWMABreaker threshold must be between 0 and 1" )
135
+ }
136
+
132
137
return nil
133
138
}
134
139
@@ -222,6 +227,11 @@ func (s *SlidingWindowBreaker) apply(o *options) error {
222
227
if o .halfOpenDelay == 0 || o .halfOpenDelay > s .windowSize {
223
228
o .halfOpenDelay = s .windowSize
224
229
}
230
+
231
+ if s .threshold < 0 || s .threshold > 1 {
232
+ return fmt .Errorf ("SlidingWindowBreaker threshold must be between 0 and 1" )
233
+ }
234
+
225
235
return nil
226
236
}
227
237
Original file line number Diff line number Diff line change @@ -44,7 +44,7 @@ func IgnoreContextCanceled(err error) bool {
44
44
return err != nil && ! errors .Is (err , context .Canceled )
45
45
}
46
46
47
- // WithMiddleware allows wrapping the [Breaker] via a [BreakerMiddleware].
47
+ // WithBreakerMiddleware allows wrapping the [Breaker] via a [BreakerMiddleware].
48
48
// Middlewares are processed from innermost to outermost, meaning the first added middleware is the closest to the
49
49
// wrapped function.
50
50
// ⚠️ This means ordering is significant: since "outer" middleware may react differently depending on the output of
You can’t perform that action at this time.
0 commit comments