SGrondin / bottleneck

Job scheduler and rate limiter, supports Clustering
MIT License
1.84k stars 79 forks source link

Throw error for invalid settings #203

Open vince1995 opened 2 years ago

vince1995 commented 2 years ago

Hey, I was struggeling a lot because I thought there's something wrong in my code. But now I figured out, that I initialized the Bottleneck with "invalid" settings:

new Bottleneck({
    minTime: 50,
    reservoir: 50,
    reservoirRefreshInterval: 5000,
});

The Bottleneck refreshs every 5 seconds the resevoir, but I forgot to set reservoirRefreshAmount (because I thought that reservoir will be used for that). I think it would be good for other developers that if reservoirRefreshAmount is set it throws an error if reservoirRefreshAmount is not set (and vice versa). Same for reservoirIncreaseInterval and reservoirIncreaseAmount.