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] ReturngetRetryAfter() method usage#19205

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

Closed
ERuban wants to merge0 commits intosymfony:5.4fromERuban:fix_rate_limiter_page

Conversation

@ERuban
Copy link

We cannot useRateLimit->calculateTimeForTokens(1, 1) there, bcs it is fromSlidingWindow class

Copy link
Member

@wouterjwouterj left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

You're 100% correct that we shouldn't use this (internal) method as public API.

$headers = [
'X-RateLimit-Remaining' => $limit->getRemainingTokens(),
'X-RateLimit-Retry-After' => $limit->calculateTimeForTokens(1, 1),
'X-RateLimit-Retry-After' => $limit->getRetryAfter()->getTimestamp(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

The header must contain the number of seconds from now to retry I believe. So we can do something like:

Suggested change
'X-RateLimit-Retry-After' => $limit->getRetryAfter()->getTimestamp(),
'X-RateLimit-Retry-After' =>now() -$limit->getRetryAfter()->getTimestamp(),

And then adduse function Symfony\Component\Clock\now; at the top of the example.

@OskarStarkOskarStark modified the milestones:6.4,5.4Dec 9, 2023
@OskarStark
Copy link
Contributor

OskarStark commentedDec 9, 2023
edited
Loading

I will take of the comments while merging, usingtime() overnow() for now and switch

- 'X-RateLimit-Retry-After' => now() - $limit->getRetryAfter()->getTimestamp(),+ 'X-RateLimit-Retry-After' => $limit->getRetryAfter()->getTimestamp() - time(),

@OskarStarkOskarStark changed the base branch from6.4 to5.4December 9, 2023 09:37
@OskarStark
Copy link
Contributor

I am very sorry@ERuban I am not sure what happened, but my an error happened while merging your PR, I applied the change myself ine1e9205

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

Reviewers

@wouterjwouterjwouterj left review comments

@xabbuhxabbuhAwaiting requested review from xabbuh

Assignees

No one assigned

Projects

None yet

Milestone

5.4

Development

Successfully merging this pull request may close these issues.

4 participants

@ERuban@OskarStark@wouterj@carsonbot

[8]ページ先頭

©2009-2025 Movatter.jp