-
Notifications
You must be signed in to change notification settings - Fork 801
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
Generate rate limit frontend api handler #5636
Conversation
Pull Request Test Coverage Report for Build 018d6b8b-50b8-4c5f-95e5-5177c23645c8
💛 - Coveralls |
28aa13e
to
50d3d50
Compare
37fa6eb
to
091050e
Compare
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.
gonna stick myself in here for "I think this needs a careful read before approval, but broadly I like it". I just don't have the brain energy to do that right now.
main concern is that this makes a significant change to when the call occurs, and that needs to be verified to be safe.
whether we return a 429 or "bad request" error on floods of bad requests: eh, I think both are defensible, changing it seems fine to me. it's just worth checking if there are any particularly valuable ones that will be lost (I sincerely doubt it).
func (h *apiHandler) allowDomain(requestType ratelimitType, domain string) bool { | ||
switch requestType { | ||
case ratelimitTypeUser: | ||
return h.userRateLimiter.Allow(quotas.Info{Domain: domain}) | ||
case ratelimitTypeWorker: | ||
return h.workerRateLimiter.Allow(quotas.Info{Domain: domain}) | ||
case ratelimitTypeVisibility: | ||
return h.visibilityRateLimiter.Allow(quotas.Info{Domain: domain}) | ||
default: | ||
panic("coding error, unrecognized request ratelimit type value") | ||
} | ||
} |
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 is a fairly minimal change and if you prefer that then 👍 but:
we could take this opportunity to remove this method and the iota and directly call the appropriate limiter.
I didn't do that initially when adding these, to keep things minimal, but it's definitely due for a cleanup at some point. Does not have to be now though.
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.
All done with a round-1 careful read!
A couple smallish changes worth verifying, but other than those / check comments, this all looks good. should be pretty easy to re-review after those things are checked/changed.
f95adb7
to
6662f3c
Compare
if rp1 == nil { | ||
err = validate.ErrRequestNotSet | ||
return | ||
} | ||
if rp1.TaskToken == nil { | ||
err = validate.ErrTaskTokenNotSet | ||
return | ||
} |
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.
at some point we should probably make some validation-wrappers that occur early and get rid of this need at random levels...
but 👍 yep, same as existing behavior, LGTM. I've been trying to come up with a nice way to build that kind of validator, but everything feels like a huge pain / very disconnected from where the checks matter...
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.
Yep, looks good! Thanks for the template-ization, the more we can standardize and pull out of the handlers the better 👍
What changed?
Generate rate limit frontend api handler code
Some fix:
Why?
To reduce manual work
How did you test it?
Potential risks
Release notes
Documentation Changes