internal

package
v0.3.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 7, 2020 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
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

func DefaultGithubErrChecker() func(error) bool

DefaultGithubErrChecker is a GithubErrChecker set up with a default amount of retries and the default sleep function.

func GithubErrChecker

func GithubErrChecker(maxTries int, sleeper func(time.Duration)) func(error) bool

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL