retry

package
v0.37.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2024 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 added in v0.12.0

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

Is returns true iff one of the two errors held in e is equal to target.

Jump to

Keyboard shortcuts

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