Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

[RateLimiter] AddCalendarWindowLimiter#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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Crovitche-1623 wants to merge40 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromCrovitche-1623:feat/calendar-window-rate-limiter

Conversation

@Crovitche-1623
Copy link
Contributor

@Crovitche-1623Crovitche-1623 commentedOct 22, 2025
edited
Loading

QA
Branch?7.4
Bug fix?no
New feature?yes
Deprecations?no
Issues
LicenseMIT

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 afixed_window policy, 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 thisCalendarWindowLimiter that can rate limit based on the givenCalendarInterval enum value.

The usage would be something like that :

# config/packages/rate_limiter.yamlframework:rate_limiter:a_gafam_api_that_gives_a_free_quota:policy:calendar_windowlimit:10000calendar_interval:month

fuzoh reacted with heart emoji
@Crovitche-1623
Copy link
ContributorAuthor

Crovitche-1623 commentedOct 24, 2025
edited
Loading

@stof The CI seems to fail because thePsr\Clock\ClockInterface interface is not found in a test. The other limiters were not developed using PSR-20ClockInterface but regulartime() functions and mocked using theClockMock offered by the PhpUnit Bridge.

What should I do in this case? Rewrite the code using regulartime() functions or require thepsr/clock at least in--dev for testing?

@stof
Copy link
Member

you need to add a dev requirement for that optional dependency.

Crovitche-1623 reacted with thumbs up emoji

@Crovitche-1623
Copy link
ContributorAuthor

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 inCalendarWindowLimiter.php?

@stof
Copy link
Member

the clock is optional in that limiter.

Crovitche-1623 reacted with thumbs up emoji

@Crovitche-1623
Copy link
ContributorAuthor

Everything seems fine on my end 😁. The tests that crashed in CI don't seem to be related to my code.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@stofstofAwaiting requested review from stof

Assignees

No one assigned

Projects

None yet

Milestone

7.4

Development

Successfully merging this pull request may close these issues.

3 participants

@Crovitche-1623@stof@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp