jhurliman/node-rate-limiter

Wait from final request of the interval rather than the first

Opened this issue · 0 comments

Currently, the number of seconds to wait is this.curIntervalStart + this.tokenBucket.interval - now. Instead I'd like to have the limiter wait for just this.tokenBucket.interval instead.

Example:-
Consider rate limit to be 10 per minute. Assume each request takes 2 seconds to execute.

curIntervalStart = 0th second
Request 1 = 2nd second
Request 2 = 4th second
....
Request 10 = 20th second

The current system would wait and restart at the 60th second(0+60), but I'd like it to wait and restart at the 80th second(20+60).

If this can be done, I'd be happy to help implement this.