internal

package
v0.9.20 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2022 License: Apache-2.0 Imports: 6 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 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.

Jump to

Keyboard shortcuts

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