Skip to content

Commit

Permalink
refactor: do not allow zero valued circuits
Browse files Browse the repository at this point in the history
This should make the code less surprising: calling a nil function
variable panics, so calling a zero value circuit is analogous to that.
  • Loading branch information
costela committed Oct 11, 2023
1 parent cdd3805 commit bf3909f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion breaker.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ type EWMABreaker struct {
// higher sample counts to avoid opening up on small hiccups.
//
// The failureThreshold is the failure rate above which the breaker should open (0.0-1.0).
func NewEWMABreaker(sampleCount int, failureThreshold float64) *EWMABreaker {
func NewEWMABreaker(sampleCount uint, failureThreshold float64) *EWMABreaker {
e := &EWMABreaker{
// https://en.wikipedia.org/wiki/Exponential_smoothing
decay: 2 / (float64(sampleCount)/2 + 1),
Expand Down

0 comments on commit bf3909f

Please sign in to comment.