CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 22k
RateLimiting: support method names for :by
and :with
#53146
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
Conversation
562ce2a
to
eaffb73
Compare
9b8a76d
to
4d80fee
Compare
8683832
to
061a682
Compare
061a682
to
5ab22ed
Compare
c4fa7b0
to
d2a1119
Compare
I get what you are implementing, but a pull request should specially contains why are you implementing. What are you trying to do that you can't without this change? |
cab31ae
to
988cf9c
Compare
Thank you for that guidance. I've updated the pull request to compare a use case before and after. |
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.
Approving the idea, but this needs a rebase after some features that I changed.
module RateLimiting | ||
extend ActiveSupport::Concern | ||
|
||
RateLimit = Struct.new(:name, :count, :retry_after) # :nodoc: |
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.
This should be documented, no? Otherwise people will not know there is a name, count and retry_after methods in the request rate_limit
. We should also document the methods in the request and response
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 introduction of the RateLimit
class, as well as changes to ActionDispatch::Request
and ActionDispatch::Response
were not necessary to include for the sake of this PR's main purpose (passing options like with: :handle_too_many_requests
instead of with: -> { handle_too_many_request }
).
I've removed those changes from this PR and have opened #55502 instead, so that those changes can be reviewed on their own.
That PR removes the # :nodoc:
and adds additional comments for documentation.
988cf9c
to
29c3d9c
Compare
Can you rebase this PR? |
Prior to this commit, `:by` and `:with` options only supported callables. This commit aims to bring rate limiting closer in parity to callbacks declarations like `before_action` and `after_action` by supporting instance method names as well.
29c3d9c
to
63166fe
Compare
Motivation / Background
Prior to this commit,
:by
and:with
options only supported callables. This commit aims to bring rate limiting closer in parity to callbacks declarations likebefore_action
andafter_action
by supporting instance method names as well.Without this change, multi-line customized callables can make declarations difficult to read. Similarly, shared customization would require a local variable to be re-used. For example:
Detail
After this change, method names can be used and shared:
Checklist
Before submitting the PR make sure the following are checked:
[Fix #issue-number]