retry

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NotSetName = "Name not set"
)

Variables

This section is empty.

Functions

func SetGlobalDefaultLogger

func SetGlobalDefaultLogger(logger log.Logger)

SetGlobalDefaultLogger Deprecated: global logger used for backward compatibility in dhctl with deprecated functions NewLoop and NewSilentLoop Please use NewLoopWithParams and NewSilentLoopWithParams

func SetGlobalInterruptChecker

func SetGlobalInterruptChecker(checker GlobalInterruptChecker)

Types

type BreakPredicate

type BreakPredicate func(err error) bool

func IsErr

func IsErr(err error) BreakPredicate

type GlobalInterruptChecker

type GlobalInterruptChecker func() bool

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. Deprecated: use NewLoopWithParams in futures versions NewLoop will take Params

func NewLoopWithParams

func NewLoopWithParams(params Params) *Loop

func NewLoopWithParamsOpts

func NewLoopWithParamsOpts(opts ...ParamsBuilderOpt) *Loop

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. Deprecated: use NewSilentLoopWithParams in futures versions NewSilentLoop will take Params

func NewSilentLoopWithParams

func NewSilentLoopWithParams(params Params) *Loop

func NewSilentLoopWithParamsOpts

func NewSilentLoopWithParamsOpts(opts ...ParamsBuilderOpt) *Loop

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

type Params

type Params interface {
	Name() string
	Attempts() int
	Wait() time.Duration
	Logger() log.Logger

	Clone(overrides ...ParamsBuilderOpt) Params
}

func NewEmptyParams

func NewEmptyParams(opts ...ParamsBuilderOpt) Params

func NewParams

func NewParams(name string, attempts int, wait time.Duration) Params

NewParams Deprecated: use NewEmptyParams with options will be private

func SafeCloneOrNewParams

func SafeCloneOrNewParams(p Params, opts ...ParamsBuilderOpt) Params

type ParamsBuilderOpt

type ParamsBuilderOpt func(Params)

func AttemptsWithWaitOpts

func AttemptsWithWaitOpts(attempts int, wait time.Duration) []ParamsBuilderOpt

func LoggerWithNameOpts added in v0.7.0

func LoggerWithNameOpts(logger log.Logger, format string, args ...any) []ParamsBuilderOpt

func WithAttempts

func WithAttempts(attempts int) ParamsBuilderOpt

func WithLogger

func WithLogger(logger log.Logger) ParamsBuilderOpt

func WithName

func WithName(format string, args ...any) ParamsBuilderOpt

func WithWait

func WithWait(wait time.Duration) ParamsBuilderOpt

Jump to

Keyboard shortcuts

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