Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

Open
wants to merge 1 commit into
base: 7.3
Choose a base branch
Loading
from

Conversation

xabbuh
Copy link
Member

@xabbuh xabbuh commented Feb 3, 2023

Q A
Branch? 7.2
Bug fix? no
New feature? yes
Deprecations? no
Tickets Fix #47999
License MIT
Doc PR

@xabbuh xabbuh force-pushed the issue-47999 branch 4 times, most recently from b4b0904 to c1b4bde Compare February 7, 2023 15:24
@nicolas-grekas
Copy link
Member

As discussed on Slack some classes are meant to be serialized (Window, SlidingWindow, TokenBucket, maybe others).
We need to figure out a way to use the current clock for them.
I think this means we shouldn't change their constructor but instead add and use a withClock method.
WDYT?

@nicolas-grekas nicolas-grekas modified the milestones: 6.3, 6.4 May 23, 2023
@nicolas-grekas nicolas-grekas modified the milestones: 6.4, 7.1 Nov 15, 2023
@fabpot
Copy link
Member

fabpot commented Feb 6, 2024

@nicolas-grekas @xabbuh What are the next steps here?

@xabbuh xabbuh modified the milestones: 7.1, 7.2 Apr 25, 2024
@xabbuh xabbuh force-pushed the issue-47999 branch 2 times, most recently from d854101 to a7af865 Compare July 30, 2024 09:44
@xabbuh xabbuh force-pushed the issue-47999 branch 2 times, most recently from caefae2 to 85a6a5d Compare July 30, 2024 11:36
@xabbuh
Copy link
Member Author

xabbuh commented Jul 30, 2024

I have updated the PR to explicitly set the clock for LimiterStateInterface implementations after they have been unserialised. It's ready from my side.

reviews welcome

@OskarStark OskarStark changed the title [RateLimiter] add the ability to use a Clock inside the RateLimiter [RateLimiter] add the ability to use a Clock inside the RateLimiter Jul 30, 2024
Copy link
Member

@nicolas-grekas nicolas-grekas left a 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.

@fabpot fabpot modified the milestones: 7.2, 7.3 Nov 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[RateLimiter] Make time dependency explicit and mockable
8 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.