shared

package
v0.0.0-...-e560ebb Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: BSD-3-Clause Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// LongerOpts gives a longer timeout than default to for gitiles quota
	// issues (~5 minutes).
	LongerOpts = Options{BaseDelay: 5 * time.Second, BackoffBase: 2.0, Retries: 5}
	// DefaultOpts is the default timeout (~30 seconds).
	DefaultOpts = Options{BaseDelay: time.Second, BackoffBase: 2.0, Retries: 5}
)

Functions

func DoWithRetry

func DoWithRetry(ctx context.Context, retryOpts Options, doFunc DoFunc) error

DoWithRetry executes function doFunc. If there is an error, it will retry with a backoff delay until max retry times reached or context done. If retryOpts.Retries == 0, it will execute doFunc just once without any retries. If retryOpts.Retries < 0, it retries an infinite number of times.

Types

type DoFunc

type DoFunc func() error

DoFunc is a function type that can be retried by DoWithRetry if the return error is not nil.

type Options

type Options struct {
	BaseDelay   time.Duration // backoff base delay.
	BackoffBase float64       // base for exponential backoff
	Retries     int           // allowed number of retries.
}

Options wraps retry options.

Jump to

Keyboard shortcuts

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