-
Notifications
You must be signed in to change notification settings - Fork 59
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
PERSONA-180 run rate limit when there is a response #127
PERSONA-180 run rate limit when there is a response #127
Conversation
…e api with 4XX errors
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.
Such a simple solution, I love this.
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.
Actually, one question on this
rest/client.go
Outdated
@@ -164,6 +164,12 @@ func SetDDIAPI() func(*Client) { | |||
// non-2XX response. | |||
func (c Client) Do(req *http.Request, v interface{}) (*http.Response, error) { | |||
resp, err := c.httpClient.Do(req) | |||
|
|||
if resp != nil { |
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.
Can we move this check below the if err != nil
beneath this? I don't think there's a reason to eschew Go's convention for error checking immediately after the func call, since HTTP error status code does not result in httpClient.Do
returning an err
, right?
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.
If the "doer" doesn't return any errors for the requests that have responses, it makes sense to move it down after the first error checking. I am testing, if everything works well I will make another commit moving it
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.
I moved since it seems what you said is correct, so it makes senses to keep it after the first error checking
8427723
to
571c6b1
Compare
571c6b1
to
e610b7b
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.
🔥
When an error occurs the client will not run the rate limit, which causes too many requests to be fired and then will hit the endpoints rate limit. So to avoid this, the rate limit function will be run when there is a response from the client payload. This was noticed when running terraform provider with invalid fields, which caused 400 errors