retry

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2024 License: MIT Imports: 6 Imported by: 14

Documentation

Overview

Package retry provides a simple yet powerful retry mechanism for Go.

Index

Constants

This section is empty.

Variables

View Source
var ErrMaxAttempts = errors.New("max attempts reached")

ErrMaxAttempts is returned when the maximum number of retry attempts is reached.

View Source
var ErrMaxTime = errors.New("max time reached")

ErrMaxTime is returned when the maximum time for all retry attempts is reached.

View Source
var ErrUnknown = errors.New("unknown error")

ErrUnknown is returned when an unknown error occurs.

Functions

func WithBackoff

func WithBackoff(ctx context.Context, doFunc RetryableFunc, configurators ...WithBackoffConfigurator) error

WithBackoff retries the given function with exponential backoff.

Types

type RetryableFunc

type RetryableFunc func(ctx context.Context) error

RetryableFunc is a function that can be retried.

type WithBackoffConfigurator

type WithBackoffConfigurator func(*retryWithBackoffConfig)

WithBackoffConfigurator configures a retryWithBackoffConfig.

func WithFactor

func WithFactor(factor float64) WithBackoffConfigurator

WithFactor sets the backoff factor.

func WithJitter

func WithJitter(jitter bool) WithBackoffConfigurator

WithJitter enables or disables jitter.

func WithMax

WithMax sets the maximum backoff duration.

func WithMaxAttemptTime

func WithMaxAttemptTime(maxAttemptTime time.Duration) WithBackoffConfigurator

WithMaxAttemptTime sets the maximum time of all retry attempts.

func WithMaxAttempts

func WithMaxAttempts(maxAttempts int) WithBackoffConfigurator

WithMaxAttempts sets the maximum number of retry attempts.

func WithMaxTotalTime added in v0.0.72

func WithMaxTotalTime(maxTotalTime time.Duration) WithBackoffConfigurator

WithMaxTotalTime sets the maximum time of all retry attempts combined.

func WithMin

WithMin sets the minimum backoff duration.

Jump to

Keyboard shortcuts

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