gocloud.dev: gocloud.dev/internal/retry Index | Files

package retry

import "gocloud.dev/internal/retry"

Package retry provides retry logic.

Index

Package Files

retry.go

func Call Uses

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.

type ContextError Uses

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 Uses

func (e *ContextError) Error() string

func (*ContextError) Is Uses

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

Package retry imports 4 packages (graph) and is imported by 4 packages. Updated 2019-03-23. Refresh now. Tools for package owners.