Throttler can access bucket for bucket life time #2074
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I was encountering an issue with the rate limiting which was causing it not to behave as expected.
If i set a rate limit of 1 request a minute, I would be able to make much more than 1 request a minute provided that the requests are a few seconds apart.
This is because the original "bucket"'s life time gets updated to the time between the 1st and 2nd request, meaning the 3rd request typically creates a new "bucket".
Edit
Added an additional commit to resolve an additional issue regarding calculating how many seconds must pass before a new token is available. (8e0ab84)
Added an additional commit to update ThrottleTest to getTokenTime() to have a value greater than 1 (1eac5c1)
Checklist: