10000 [RateLimiter] Added reserve() to LimiterInterface and rename Limiter to RateLimiter by wouterj · Pull Request #38562 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RateLimiter] Added reserve() to LimiterInterface and rename Limiter to RateLimiter #38562

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 16, 2020

Conversation

wouterj
Copy link
Member
@wouterj wouterj commented Oct 14, 2020
Q A
Branch? 5.x
Bug fix? no
New feature? yes
Deprecations? no
Tickets -
License MIT
Doc PR -

While Javier wrote documentation for this new component, we found a couple of confusing elements that might need some tweaks:

  • The Limiter class (previously called LimiterFactory) has imho a bit strange name, as it's not a limiter and it doesn't implement LimiterInterface. It can only new limiters. I believe LimiterFactory - like LockFactory - would be the most clear, but as that was rejected before, here is another proposal using RateLimiter.
  • reserve() was now only part of the token bucket implementation. That made it a bit less useful. I think I've found a way to also allow reserving future hits in the fixed window implementation, so I've moved it to the LimiterInterface.

@Nyholm
Copy link
Member
Nyholm commented Oct 14, 2020

👍 for RateLimiter

@nicolas-grekas nicolas-grekas added this to the 5.2 milestone Oct 14, 2020
@nicolas-grekas
Copy link
Member

(rebase needed)

@wouterj wouterj force-pushed the ratelimiter/doc-improvements branch 2 times, most recently from b1776ee to 5e3991d Compare October 14, 2020 18:18
Copy link
Member
@fabpot fabpot left a comment

Choose a reason for hiding this comment

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

Ready IMHO when the TODO is resolved

@fabpot fabpot force-pushed the ratelimiter/doc-improvements branch from 783875d to cd34f21 Compare October 16, 2020 05:10
@fabpot
Copy link
Member
fabpot commented Oct 16, 2020

Thank you @wouterj.

@fabpot fabpot merged commit abbb3d0 into symfony:5.x Oct 16, 2020
chalasr added a commit that referenced this pull request Oct 22, 2020
This PR was merged into the 5.x branch.

Discussion
----------

[RateLimiter] Remove Window::sleep()

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? |
| Tickets       |
| License       | MIT
| Doc PR        |

This function is not needed since #38562

Commits
-------

ccbf7d5 [RateLimiter] Remove Window::sleep()
chalasr added a commit that referenced this pull request Oct 24, 2020
…holm)

This PR was squashed before being merged into the 5.x branch.

Discussion
----------

[RateLimiter] Rename RateLimiter to RateLimiterFactory

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | No, not released yet
| Tickets       |
| License       | MIT
| Doc PR        | should be added

Sorry for making a few BC breaks.

@wouterj [said](#38562 (comment)) that this class was suggested to be named `LimiterFactory` before. But that was rejected.

Just my looking at the names of the classes we currently have:
- Rate
- RateLimit
- RateLimiter

I find it hard to know what these are doing and the difference between them. Note that none of them are used as a rate limiter (ie implements `LimiterInterface`)

I would like to be clear that a `RateLimiterFactory` is used to create an object implementing `LimiterInterface`.

Commits
-------

8be261b [RateLimiter] Rename RateLimiter to RateLimiterFactory
symfony-splitter pushed a commit to symfony/rate-limiter that referenced this pull request Oct 24, 2020
…holm)

This PR was squashed before being merged into the 5.x branch.

Discussion
----------

[RateLimiter] Rename RateLimiter to RateLimiterFactory

| Q             | A
| ------------- | ---
| Branch?       | 5.x
| Bug fix?      | no
| New feature?  | no
| Deprecations? | No, not released yet
| Tickets       |
| License       | MIT
| Doc PR        | should be added

Sorry for making a few BC breaks.

@wouterj [said](symfony/symfony#38562 (comment)) that this class was suggested to be named `LimiterFactory` before. But that was rejected.

Just my looking at the names of the classes we currently have:
- Rate
- RateLimit
- RateLimiter

I find it hard to know what these are doing and the difference between them. Note that none of them are used as a rate limiter (ie implements `LimiterInterface`)

I would like to be clear that a `RateLimiterFactory` is used to create an object implementing `LimiterInterface`.

Commits
-------

8be261b300 [RateLimiter] Rename RateLimiter to RateLimiterFactory
@fabpot fabpot mentioned this pull request Oct 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants
0