repeater

package
v0.0.0-...-f7b84e4 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package repeater calls a function until it returns no error, up to some number of iterations and delays defined by strategy

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExponentialBackoff

type ExponentialBackoff struct {
	InitialInterval     time.Duration
	MaxElapsedTime      time.Duration
	Multiplier          float64
	RandomizationFactor float64
}

func (ExponentialBackoff) Start

func (s ExponentialBackoff) Start(ctx context.Context) <-chan struct{}

type Repeater

type Repeater struct {
	Strategy
}

func New

func New(strategy Strategy) *Repeater

func (Repeater) Do

func (r Repeater) Do(ctx context.Context, fn func(context.Context) error) error

type Strategy

type Strategy interface {
	Start(context.Context) <-chan struct{}
}

func DefaultExponentialBackoff

func DefaultExponentialBackoff() Strategy

func FixedDelay

func FixedDelay(repeats int, delay time.Duration) Strategy

func Once

func Once() Strategy

Jump to

Keyboard shortcuts

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