Documentation ¶
Index ¶
Constants ¶
const ( // MaxGithubRetries is the maximum amount of times we flag a GitHub error as // retryable before we give up and do not flag the same call as retryable // anymore. MaxGithubRetries = 3 )
Variables ¶
This section is empty.
Functions ¶
func DefaultGithubErrChecker ¶
DefaultGithubErrChecker is a GithubErrChecker set up with a default amount of retries and the default sleep function.
func GithubErrChecker ¶
GithubErrChecker returns a function that checks errors from GitHub and decides if they can / should be retried. It needs to be called with `maxTries`, a number of retries a single call should be retried at max, and `sleeper`, a function which implements the sleeping.
Currently only the `github.RateLimitError` and `github.AbuseRateLimitError` return values are supported. If one of those errors occur, then we sleep for a default duration or the amount of time the error told us to wait.
Other special errors should be easy to implement too.
It can be used like this:
for shouldRetry := GithubErrChecker(10, time.Sleep); ; { commit, res, err := github_client.GetCommit(...) if !shouldRetry(err) { return commit, res, err } }
Types ¶
This section is empty.