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] Use RateLimiterFactory with custom limit#51403

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
IlonavD wants to merge4 commits intosymfony:7.4
base:7.4
Choose a base branch
Loading
fromIlonavD:issue-51401

Conversation

IlonavD
Copy link

@IlonavDIlonavD commentedAug 16, 2023
edited
Loading

Add an optional custom limit to the RateLimiterFactory to overwrite configured values.

QA
Branch?6.4
Bug fix?no
New feature?yes
Deprecations?no
TicketsFix#51401
LicenseMIT
Doc PRsymfony/symfony-docs#...

The RateLimiterFactory by default uses the limit set in Config. However in certain situations you might want to change this limit per user. This allows for for that option. When no limit is passed to the Factory, the default configured value will be used.

arjenschol reacted with thumbs up emoji
Add an optional custom limit to the RateLimiterFactory to overwrite configured values.
@carsonbot
Copy link

Hey!

I see that this is your first PR. That is great! Welcome!

Symfony has acontribution guide which I suggest you to read.

In short:

  • Always add tests
  • Keep backward compatibility (seehttps://symfony.com/bc).
  • Bug fixes must be submitted against the lowest maintained branch where they apply (seehttps://symfony.com/releases)
  • Features and deprecations must be submitted against the 6.4 branch.

Review the GitHub status checks of your pull request and try to solve the reported issues. If some tests are failing, try to see if they are failing because of this change.

When two Symfony core team members approve this change, it will be merged and you will become an official Symfony contributor!
If this PR is merged in a lower version branch, it will be merged up to all maintained branches within a few days.

I am going to sit back now and wait for the reviews.

Cheers!

Carsonbot

* Parsing a custom limit to this function will overwrite the limit in your configuration for this request.
* When using a NoLimiter the limit will be ignored.
*/
public function create(string $key = null, int $limit = null): LimiterInterface
Copy link
Contributor

Choose a reason for hiding this comment

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

What if you also want at some point to configure the rate dynamically? A solution could be to provide the whole config instead (and resolve it), WDYT?

Suggested change
publicfunction create(string$key =null,int$limit =null):LimiterInterface
publicfunction create(string$key =null,array$config =null):LimiterInterface

Copy link
Member

Choose a reason for hiding this comment

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

this would then force to validate the provided config each time this method is called.

To me, if you want to do things dynamically, it would be better to introduce a RateLimiterFactoryInterface allowing to do a custom implementation of the factory than adding a configuration override argument.
Thus, if you are creating a custom caller for the factory, you could already instantiate the limiter yourselves. And if you don't call it yourselves (relying on a usage in Symfony), you would not be able to pass a custom config.

mtarld and yceruto reacted with thumbs up emoji
Copy link
Contributor

Choose a reason for hiding this comment

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

Indeed, I that if we add an argument to the factory method to customize it, there is no point to not adding others (even if the limit is the only common parameter).

That's why, in my opinion too, it is way better to indeed introduce aRateLimiterFactoryInterface so there is no limit to the customization.

Copy link
Author

Choose a reason for hiding this comment

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

Alright :) I will create the interface instead later this week. Thanks guys!

mtarld reacted with laugh emoji
@nicolas-grekasnicolas-grekas modified the milestones:6.4,7.1Nov 15, 2023
@ycerutoyceruto modified the milestones:6.4,7.1Nov 15, 2023
@ycerutoyceruto removed the Bug labelNov 15, 2023
@xabbuhxabbuh modified the milestones:7.1,7.2May 15, 2024
@fabpotfabpot modified the milestones:7.2,7.3Nov 20, 2024
@kbond
Copy link
Member

kbond commentedMar 26, 2025
edited
Loading

I put some ideas on this feature here:#51401 (comment)

@kbondkbond mentioned this pull requestMar 29, 2025
3 tasks
@fabpotfabpot modified the milestones:7.3,7.4May 26, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@stofstofstof left review comments

@mtarldmtarldmtarld left review comments

Assignees
No one assigned
Projects
None yet
Milestone
7.4
Development

Successfully merging this pull request may close these issues.

[RateLimiter] Use RateLimiterFactory with custom limit
10 participants
@IlonavD@carsonbot@kbond@stof@mtarld@fabpot@nicolas-grekas@xabbuh@yceruto@Dooij

[8]ページ先頭

©2009-2025 Movatter.jp