retry

package
v2.3.2 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Permanent

func Permanent(err error) error

Permanent wraps err so that Retry stops immediately.

func Retry

func Retry(ctx context.Context, b *ExponentialBackoff, operation func() error) error

Retry calls operation until it succeeds, returns a PermanentError, or the context/elapsed time limit is exceeded.

Types

type ExponentialBackoff

type ExponentialBackoff struct {
	InitialInterval time.Duration
	MaxInterval     time.Duration
	MaxElapsedTime  time.Duration // 0 means no limit
	// contains filtered or unexported fields
}

ExponentialBackoff holds configuration for exponential backoff retry.

func (*ExponentialBackoff) NextBackOff

func (b *ExponentialBackoff) NextBackOff() time.Duration

NextBackOff returns the next wait interval, capped at MaxInterval.

func (*ExponentialBackoff) Reset

func (b *ExponentialBackoff) Reset()

Reset resets the backoff interval to initial state.

type PermanentError

type PermanentError struct {
	Err error
}

PermanentError wraps an error to signal that retrying should stop.

func (*PermanentError) Error

func (e *PermanentError) Error() string

func (*PermanentError) Unwrap

func (e *PermanentError) Unwrap() error

Jump to

Keyboard shortcuts

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