Go-github: Add support for retrying certain operations automatically

Created on 17 Mar 2016  路  2Comments  路  Source: google/go-github

It would be very nice if certain operations included support for automatically retrying failed operations. For example, the code that uploads assets to a release should probably retry automatically (possibly using something like pester?) when there is a 502 failure

question

Most helpful comment

I'm not sure it's go-github's place to decide how users of the library should respond to particular API errors. That's precisely why every method returns the Response object, so that the caller can inspect that and decide how to respond themselves. Some users might want to continue retrying, while others might want to handle it differently.

pester looks kinda neat, I hadn't seen that before. If it could wrap it's logic into an http.RoundTripper (I haven't looked closely enough to know if that actually makes sense or not), then you could just pass an http.Client that contains a "PesterTransport" and use it with go-github without modification. That's exactly how the oauth integration works.

All 2 comments

I'm not sure it's go-github's place to decide how users of the library should respond to particular API errors. That's precisely why every method returns the Response object, so that the caller can inspect that and decide how to respond themselves. Some users might want to continue retrying, while others might want to handle it differently.

pester looks kinda neat, I hadn't seen that before. If it could wrap it's logic into an http.RoundTripper (I haven't looked closely enough to know if that actually makes sense or not), then you could just pass an http.Client that contains a "PesterTransport" and use it with go-github without modification. That's exactly how the oauth integration works.

Agreed, I don't think it's possible to have one-size-fits all policy for retrying that is acceptable for all users of the library. It belongs in a higher level.

A somewhat related issue/question is #431.

Was this page helpful?
0 / 5 - 0 ratings