retry

package
v0.8.1 Latest Latest
Warning

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

Go to latest
Published: Apr 11, 2021 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Overview

Package retry implements exponential retry policy.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Always added in v0.5.2

func Always(err error) bool

Always is a retry function that retries all errors.

func Never added in v0.8.0

func Never(err error) bool

Never is a retry function that never retries.

func Periodically added in v0.5.2

func Periodically(ctx context.Context, interval time.Duration, count int, desc string, attempt AttemptFunc, isRetriableError IsRetriableFunc) (interface{}, error)

Periodically runs the provided attempt until it succeeds, waiting given fixed amount between attempts.

func PeriodicallyNoValue added in v0.5.2

func PeriodicallyNoValue(ctx context.Context, interval time.Duration, count int, desc string, attempt func() error, isRetriableError IsRetriableFunc) error

PeriodicallyNoValue runs the provided attempt until it succeeds, waiting given fixed amount between attempts.

func WithExponentialBackoff

func WithExponentialBackoff(ctx context.Context, desc string, attempt AttemptFunc, isRetriableError IsRetriableFunc) (interface{}, error)

WithExponentialBackoff runs the provided attempt until it succeeds, retrying on all errors that are deemed retriable by the provided function. The delay between retries grows exponentially up to a certain limit.

func WithExponentialBackoffNoValue

func WithExponentialBackoffNoValue(ctx context.Context, desc string, attempt func() error, isRetriableError IsRetriableFunc) error

WithExponentialBackoffNoValue is a shorthand for WithExponentialBackoff except the attempt function does not return any value.

Types

type AttemptFunc

type AttemptFunc func() (interface{}, error)

AttemptFunc performs an attempt and returns a value (optional, may be nil) and an error.

type IsRetriableFunc

type IsRetriableFunc func(err error) bool

IsRetriableFunc is a function that determines whether an error is retriable.

Jump to

Keyboard shortcuts

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