Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork9.7k
[RateLimiter] Add SlidingWindowLimiter::reserve()#51676
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
Merged
Merged
Uh oh!
There was an error while loading.Please reload this page.
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
fabpot approved these changesOct 1, 2023
Member
fabpot commentedOct 1, 2023
Thank you@Jeroeny. |
nicolas-grekas added a commit that referenced this pull requestDec 29, 2023
…licies (wouterj)This PR was merged into the 6.3 branch.Discussion----------[RateLimit] Test and fix peeking behavior on rate limit policies| Q | A| ------------- | ---| Branch? | 6.3| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues | Ref#52835| License | MITAlthough heavily discouraged for user-land code, we've implemented peeking behavior for rate limiting in 6.2 with#46110. However, I found that our rate limit policies show very inconsistent behavior on this.As we didn't have great test covering peeking return values, we broke BC with#51676 in 6.4. I propose this PR to verify the behavior of the policies and also make it inconsistent. I target 6.3 because we rely on this in the login throttling since 6.2 and this shows buggy error messages ("try again in 0 minute") when not using the default policy for login throttling.> [!NOTE]> When merging this PR, there will be heavy merge conflicts in the SlidingWindowLimiter. You can ignore the changes in this PR for this policy in 6.4. I'll rebase and update#52835 to fix the sliding window limiter in 6.4+Commits-------e4a8c33 [RateLimit] Test and fix peeking behavior on rate limit policies
nicolas-grekas added a commit that referenced this pull requestDec 30, 2023
…when consuming 0 or last tokens (wouterj, ERuban)This PR was merged into the 6.4 branch.Discussion----------[RateLimiter] Fix RateLimit->getRetryAfter() return value when consuming 0 or last tokens| Q | A| ------------- | ---| Branch? | 6.4| Bug fix? | yes| New feature? | no| Deprecations? | no| Issues | -| License | MITReplaces#52835 Original description:> Have got some BC after updating the project to Symfony 6.4 (after that PR#51676).>> Sometimes I need to get `RateLimit` object without consuming just before consuming a try, in example:> ```php> $rateLimit = $limiter->consume(0);> if ($rateLimit->getRemainingTokens() === 0) {> throw new SomeException($rateLimit->getRetryAfter());> }> ...> $limiter->consume(1)> ...> ```> and found that in that case `$rateLimit->getRetryAfter()` always returns `now`.>> So this PR fixes it.Commits-------677b8b7 [RateLimit] Allow to get RateLimit without consuming again169e383 Reintroduce peek consume test for sliding window policy
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading.Please reload this page.
This implements
LimiterInterface->reserve()forSlidingWindowLimiter. I'm not sure if the lack of implementation was due to time/scope or if it's actually not possible and my approach is incorrect. But I like to give it a try anyway. Perhaps@wouterj you could elaborate on that?The calculation does the following:
This wasn't abugfix, so back to feature PR. I couldn't reopen#47557, So had to create this new PR.