Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork5.3k
[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
Uh oh!
There was an error while loading.Please reload this page.
Conversation
wouterj left a comment
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.
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(), |
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.
The header must contain the number of seconds from now to retry I believe. So we can do something like:
| '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.
OskarStark commentedDec 9, 2023 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
I will take of the comments while merging, using - 'X-RateLimit-Retry-After' => now() - $limit->getRetryAfter()->getTimestamp(),+ 'X-RateLimit-Retry-After' => $limit->getRetryAfter()->getTimestamp() - time(), |
4731402 toc61dc1fCompare
We cannot use
RateLimit->calculateTimeForTokens(1, 1)there, bcs it is fromSlidingWindowclass