Closed dpordomingo closed 5 years ago
build on top of #49 [implement MultiToken]
Do you need this? they should be independent as you work at transport level. I mean if this is ready, I won't wait for #49.
Integration tests testing: Retry + RateLimit
AFAIS We already have unittests, let's open a different issue for integration tests, also maybe @kyrcha could take care of it.
I found (and fixed) some bugs caused when the Request/Response are read from a Transport, which cause that they're no longer available for other Transport in the chain.
AFAIR there was already a fix for this in ghsync.
I have reproduced (I think) all of the possible HTTP codes:
for this issue #40 so tests will be added for such matters.
@se7entyse7en Yes, the rebase over #49 is needed; i.e. it's also causing the current conflict. More details in my review for that PR TL;DR you moved the Transport chain definition elsewhere, so I need to adapt this.
@se7entyse7en No, the issue about the ruined body was not added in ghsync
because there was no Request.Body
needed at all (because the query was built directly from the Request.URL
.)
More details in 00086cf920eabdfb4ccc8d6fe327ef5bb2aa8b71
.
I'll create a new PR from an upstream branch
depends on https://github.com/src-d/metadata-retrieval/pull/49 [implement MultiToken] fix https://github.com/src-d/metadata-retrieval/issues/3 [handle RateLimit errors] fix https://github.com/src-d/metadata-retrieval/issues/18 [handle Abuse errors]
TODO
Retry
+RateLimit
(Could be added in a new PR, or also in this PR)Changes grom
ghsync
github.RetryTransport
, not bygithub.RateLimitTransport
Also needed:
retryTransport
:Transport.RoundTrip
Response
&Request
when read fromTransport
Request.Body
andResponse.Body
are read from anytransport.RoundTrip
, it is needed to restore them before reusing it again; otherwise, theirBody
won't be readable from other nestedTransport
.How does it work?
Trying to fetch an
org
with a GH token under anAbuseRateLimmit
block, whosequota
also expired:github.Downloader
tries to get the data, but GH answers with n403, AbuseRateLimmit
,github.RateLimitTransport
, and the lock is enabled for the time specified by the headers from the403, AbuseRateLimmit
; the error is bubbled upgithub.RetryTransport
, and retriedgithub.RateLimitTransport
is locked, so it sleeps till the lock expires.AbuseRateLimmit
will disappear, but in this example, it appeared aRateLimmit
for that same query which is intercepted again bygithub.RateLimitTransport
, and the lock is enabled again for the time specified by the headers from the200, StatusOk
; the error is bubbled upgithub.RetryTransport
, and retriedgithub.RateLimitTransport
is locked, so it sleeps till the lock expires.