backoff

package
v0.22.5 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Retry

func Retry(ns string, f func() error, s Strategy) error

Retry is a helper function to retry an operation with the given strategy. It returns an error if the operation fails after all retries.

func RetryExponential

func RetryExponential(ns string, f func() error) error

RetryExponential is a helper function to retry an operation with exponential backoff.

func RetryFixed

func RetryFixed(ns string, f func() error) error

RetryFixed is a helper function to retry an operation with fixed backoff.

Types

type Strategy

type Strategy struct {
	// Maximum number of retries before giving up (inclusive)
	// Default is 5
	MaxRetries int // Maximum number of retries before giving up (inclusive)
	// Maximum delay to use between retries (in milliseconds)
	// If Exponential is true, this is the initial delay
	// Default is 1000
	Delay int

	// Whether to use exponential backoff or not (if false, constant delay is used)
	// Default is false
	Exponential bool
	// Maximum duration to wait between retries (in milliseconds)
	// Default is 10 seconds
	MaxDuration time.Duration
}

Strategy is a configuration for the backoff strategy to use when retrying operations.

Jump to

Keyboard shortcuts

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