[9.x] Add a separate Rate Limiting Service Provider (Deferrable) #34843
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.
With expanding the scope of RateLimiters to jobs as well (#34829), it might be the right time to introduce a
RateLimitingServiceProvider
in 9.x. This can be where users can register all their rate limiters so that there's a dedicated provider to do so (instead of usingAppServiceProvider
for jobs andRouteServiceProvider
for routes).Also, this should improve performance slightly as it is a deferrable provider, so the named rate limiter registrations would only trigger when the app resolves the
RateLimiter
.This is a breaking change because I'm extracting out the
RateLimiter
singleton registration to a separate provider. That's why this PR targets master.If this PR is accepted, I'll send across a PR to the Laravel skeleton repo for a
RateLimiterServiceProvider
in theapp/Providers
directory that extends the base provider in this PR and registers the named rate limiters in theboot
method.