Support multi-period intervals in throttling #1373
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.
This pull request enhances the throttling functionality to support multi-period intervals, such as
5/30s
,10/5m
, and100/2h
. Previously, the throttling implementation only allowed single-period intervals (e.g.,5/s
,100/d
), which limited the granularity and flexibility of rate limits.The new implementation expands the allowed syntax for throttle rates to accommodate use cases requiring multi-unit periods, making it easier to define more precise rate limits.
Motivation
While single-period intervals work for many scenarios, they lack flexibility for more complex use cases. For example:
20/5m
(20 requests every 5 minutes) cannot be expressed with the current system.50/2h
allow finer control over bursts without spanning a full day.