fail fast when rolling window size is zero

This commit is contained in:
kevin
2020-10-15 11:40:31 +08:00
parent 6f49639f80
commit c824e9e118
3 changed files with 11 additions and 21 deletions

View File

@@ -22,6 +22,10 @@ type (
)
func NewRollingWindow(size int, interval time.Duration, opts ...RollingWindowOption) *RollingWindow {
if size < 1 {
panic("size must be greater than 0")
}
w := &RollingWindow{
size: size,
win: newWindow(size),