go: go.chromium.org/chromiumos/infra/go/internal/shared Index | Files

package shared

import "go.chromium.org/chromiumos/infra/go/internal/shared"

Index

Package Files

retry.go

Variables

var (
    DefaultOpts = Options{BaseDelay: time.Second, BackoffBase: 2.0, Retries: 5}
)

func DoWithRetry Uses

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.

type DoFunc Uses

type DoFunc func() error

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

type Options Uses

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.

Package shared imports 5 packages (graph) and is imported by 2 packages. Updated 2019-07-18. Refresh now. Tools for package owners.