Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Give longer timeout than default to for gitiles quota issues (~5 minutes).
	LongerOpts = Options{BaseDelay: 5 * time.Second, BackoffBase: 2.0, Retries: 5}
	// 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.

        Source Files