rubyist / circuitbreaker

Circuit Breakers in Go
MIT License
1.12k stars 109 forks source link

sliding window not work correctly #51

Closed ghost closed 6 years ago

ghost commented 6 years ago

When getLatestBucket is called, buckets not in current window slide should be all reset.

....

w := newWindow(time.Millisecond*10,  2)

w.Fail()
time.Sleep(time.Millisecond * 20)
w.Fail()

fmt.Println(w.Failures())

... 

When run above code, the result should be 1, not 2. As window duration is 10ms, after sleep 20ms, all buckets are expired.

ghost commented 6 years ago

Sorry for the wrong test, sliding window works as expected.