retry

package
v0.0.0-...-ff546ff Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var InTestEnvironment = false

Functions

This section is empty.

Types

type BreakPredicate

type BreakPredicate func(err error) bool

func IsErr

func IsErr(err error) BreakPredicate

type Loop

type Loop struct {
	// contains filtered or unexported fields
}

Loop retries a task function until it succeeded with number of attempts and delay between runs are adjustable.

func NewLoop

func NewLoop(name string, attemptsQuantity int, wait time.Duration) *Loop

NewLoop create Loop with features: - it is "verbose" loop — it prints messages through logboek. - this loop is interruptable by the signal watcher in tomb package.

func NewSilentLoop

func NewSilentLoop(name string, attemptsQuantity int, wait time.Duration) *Loop

NewSilentLoop create Loop with features: - it is "silent" loop — no messages are printed through logboek. - this loop is not interruptable by the signal watcher in tomb package.

func (*Loop) BreakIf

func (l *Loop) BreakIf(pred BreakPredicate) *Loop

func (*Loop) Run

func (l *Loop) Run(task func() error) error

func (*Loop) RunContext

func (l *Loop) RunContext(ctx context.Context, task func() error) error

RunContext retries a task like Run but breaks if context done.

func (*Loop) WithInterruptable

func (l *Loop) WithInterruptable(flag bool) *Loop

func (*Loop) WithLogger

func (l *Loop) WithLogger(logger log.Logger) *Loop

func (*Loop) WithShowError

func (l *Loop) WithShowError(flag bool) *Loop

Jump to

Keyboard shortcuts

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