-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[RateLimiter] Add CalendarWindowLimiter
#62127
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: 8.1
Are you sure you want to change the base?
[RateLimiter] Add CalendarWindowLimiter
#62127
Conversation
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Policy/CalendarWindowType.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Policy/CalendarWindowType.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Policy/CalendarWindowLimiter.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Policy/CalendarWindowLimiter.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Policy/CalendarWindowType.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Tests/Policy/CalendarWindowTest.php
Outdated
Show resolved
Hide resolved
…move the default value
src/Symfony/Component/RateLimiter/Policy/CalendarWindowLimiter.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
…nt is not installed
|
@stof The CI seems to fail because the What should I do in this case? Rewrite the code using regular |
|
you need to add a dev requirement for that optional dependency. |
Are we sure it's not just a regular dependency, since it's now used in |
|
the clock is optional in that limiter. |
… should be optional
|
Everything seems fine on my end 😁. The tests that crashed in CI don't seem to be related to my code. |
I was looking to rate limit an API that I proxy to another. However, the pricing for the API I am calling is based on a calendar quota (we receive the bill at the end of the month).
On Symfony, I saw that there was a
fixed_windowpolicy, which corresponds to a counter for a given interval.However, the counter seems to start when the request is made, not on a calendar basis.
I could reset the cache used by the rate_limiter at the beginning of the month to make sure it's correct, but that seemed a bit messy.
That's why I propose this
CalendarWindowLimiterthat can rate limit based on the givenCalendarIntervalenum value.The usage would be something like that :