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 the only special error that is flagged as retryable is the `AbuseRateLimitError`. If such an error occurs, we sleep for a while (the amount of time the error told us to wait) and then report back that we can retry. 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.