retry

package
v0.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 26, 2019 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package retry provides retry logic.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Call

func Call(ctx context.Context, bo gax.Backoff, isRetryable func(error) bool, f func() error) error

Call calls the supplied function f repeatedly, using the isRetryable function and the provided backoff parameters to control the repetition.

When f returns nil, Call immediately returns nil.

When f returns an error for which isRetryable returns false, Call immediately returns that error.

When f returns an error for which isRetryable returns true, Call sleeps for the provided backoff value and invokes f again.

When the provided context is done, Retry returns a ContextError that includes both ctx.Error() and the last error returned by f, or nil if there isn't one.

Types

type ContextError

type ContextError struct {
	CtxErr  error // The error obtained from ctx.Err()
	FuncErr error // The error obtained from the function being retried, or nil
}

A ContextError contains both a context error (either context.Canceled or context.DeadlineExceeded), and the last error from the function being retried, or nil if the function was never called.

func (*ContextError) Error

func (e *ContextError) Error() string

func (*ContextError) Is

func (e *ContextError) Is(target error) bool

Jump to

Keyboard shortcuts

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