ratelimitj
ratelimitj copied to clipboard
Bug in computing blockId
The computation of blockId is as follows: blockId = Math.floor(time_now/precision);
Currently, while computing the blockId in all the test cases the BanditSupplier starts the timer at perfectly rounded count of 1000000. So whenever a delta time is added to this count the blockId works as expected.
Consider the following situation: If the BanditSupplier was started with a counter of 1000007 and the Ratelimiter rule of (duration=10sec, limit = 5, precision = 10). The window starts with the blockId of (1000007/10) i.e 100000
With an elapse of 3 seconds, the timer count now is 1000010 and the corresponding blockId is 100001 which results in a different window and defeats the purpose of FixedWindowRateLimiting