-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[RateLimiter] add the ability to use a Clock
inside the RateLimiter
#49222
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: 7.3
Are you sure you want to change the base?
Conversation
xabbuh
commented
Feb 3, 2023
•
edited by yceruto
Loading
edited by yceruto
Q | A |
---|---|
Branch? | 7.2 |
Bug fix? | no |
New feature? | yes |
Deprecations? | no |
Tickets | Fix #47999 |
License | MIT |
Doc PR |
src/Symfony/Component/RateLimiter/Policy/FixedWindowLimiter.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/PhpFrameworkExtensionTest.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Policy/FixedWindowLimiter.php
Outdated
Show resolved
Hide resolved
src/Symfony/Bundle/FrameworkBundle/DependencyInjection/Configuration.php
Outdated
Show resolved
Hide resolved
src/Symfony/Component/RateLimiter/Policy/TokenBucketLimiter.php
Outdated
Show resolved
Hide resolved
b4b0904
to
c1b4bde
Compare
As discussed on Slack some classes are meant to be serialized (Window, SlidingWindow, TokenBucket, maybe others). |
@nicolas-grekas @xabbuh What are the next steps here? |
d854101
to
a7af865
Compare
caefae2
to
85a6a5d
Compare
I have updated the PR to explicitly set the clock for reviews welcome |
Clock
inside the RateLimiter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this PR should be revised with this in mind: value objects should remain free from services.
Putting a clock service in a CacheStorage doesn't make sense to me.
e.g. for the Window class, there's already a way to define the current time: always pass $now to the add() method.
This logic should be applied to challenge all added clock services, so that we add it only to services.