-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Enable Client.RateLimits
to bypass the rate limit check
#1907
Conversation
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.
Very nice, @sa-spag !
I really like this solution... I was concerned that there would be much more disruption, but this looks very nice and clean... thank you!
LGTM.
Awaiting second LGTM before merging.
Whups, sorry, it looks like the unit tests are not passing:
|
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.
Changing approval until unit tests pass.
Credits to @ViBiOh for the
Whups indeed, my bad. Got a little too confident, it is now fixed. |
Codecov Report
@@ Coverage Diff @@
## master #1907 +/- ##
=======================================
Coverage 97.65% 97.65%
=======================================
Files 105 105
Lines 6786 6788 +2
=======================================
+ Hits 6627 6629 +2
Misses 86 86
Partials 73 73
Continue to review full report at Codecov.
|
@@ -201,6 +201,9 @@ func testNewRequestAndDoFailure(t *testing.T, methodName string, client *Client, | |||
client.BaseURL.Path = "/api-v3/" | |||
client.rateLimits[0].Reset.Time = time.Now().Add(10 * time.Minute) | |||
resp, err = f() | |||
if bypass := resp.Request.Context().Value(bypassRateLimitCheck); bypass != nil { | |||
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.
I'm concerned that we are not checking the value of err
here... might there be a case where we get an error that will be ignored here?
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 helper explicitly sets the client up to trigger errors, and at this stage a rate limit error. As is, the test would fail if we check for err != nil
for methodName == "RateLimits"
as the request would result in a HTTP 404, since no handler has been created. We can set one up on TestRateLimits_coverage
but I think it makes the test less straightforward. Client.RateLimits
rate limit check bypass behavior is already covered by the newly introduced TestRateLimits_overQuota
.
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.
LGTM.
Awaiting second LGTM before merging.
Friendly ping @wesleimp |
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.
LGTM.
Fixes #1899.