retry

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2024 License: Apache-2.0 Imports: 1 Imported by: 1

README ¶

retry

A Go library to simplify retrying operations with configurable strategies like exponential backoff, fixed interval, and infinite retries.

📋 Requirements

  • Go 1.17+

🚀 Install

go get github.com/libgox/retry

Documentation ¶

Index ¶

Constants ¶

This section is empty.

Variables ¶

This section is empty.

Functions ¶

func Do ¶

func Do(fn func() error, strategy Strategy) error

func Must ¶

func Must(fn func() error, strategy Strategy)

Types ¶

type ExponentialStrategy ¶

type ExponentialStrategy struct {
	InitialInterval time.Duration
	MaxInterval     time.Duration
	Multiplier      float64
	MaxAttempts     int
	// contains filtered or unexported fields
}

func (*ExponentialStrategy) NextDelay ¶

func (e *ExponentialStrategy) NextDelay(attempt int) (time.Duration, bool)

type FibonacciStrategy ¶

type FibonacciStrategy struct {
	InitialInterval time.Duration
	MaxInterval     time.Duration
	MaxAttempts     int
	// contains filtered or unexported fields
}

func (*FibonacciStrategy) NextDelay ¶

func (f *FibonacciStrategy) NextDelay(attempt int) (time.Duration, bool)

type FixedStrategy ¶

type FixedStrategy struct {
	Interval    time.Duration
	MaxAttempts int
}

func (*FixedStrategy) NextDelay ¶

func (f *FixedStrategy) NextDelay(attempt int) (time.Duration, bool)

type Strategy ¶

type Strategy interface {
	NextDelay(attempt int) (time.Duration, bool)
}

Jump to

Keyboard shortcuts

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