exec

package
v1.4.551 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2024 License: GPL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMissingExecFn     = errors.New("no exec function provided")
	ErrMissingFallbackFn = errors.New("no fallback function provided")
)

Functions

This section is empty.

Types

type Error

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

Error holds none or multiple errors that can happen during execution.

func (*Error) AddErr

func (e *Error) AddErr(err error)

AddErr appends an error to the error slice of Error.

func (*Error) Error

func (e *Error) Error() string

Error implements the standard error interface.

type Opts

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

Opts holds the configurable options for a RetryableExecutor.

func NewDefaultExecOpts

func NewDefaultExecOpts() *Opts

NewDefaultExecOpts creates the default Opts.

type OptsFn

type OptsFn func(opts *Opts)

OptsFn is function that operate on Opts.

func WithMaxRetryCount

func WithMaxRetryCount(maxRetryCount uint) OptsFn

WithMaxRetryCount sets the max retry count.

Note that a default value is provided if the provided count is 0.

func WithRetryOnFallBackError

func WithRetryOnFallBackError(retryOnFallbackError bool) OptsFn

WithRetryOnFallBackError sets the retryOnFallbackError flag.

func WithRetryTimeout

func WithRetryTimeout(retryTimeout time.Duration) OptsFn

WithRetryTimeout sets the retry timeout.

type RetryableExecutor

type RetryableExecutor[T any] interface {
	ExecWithFallback(execFn func() (T, error), fallbackFn func() error) (T, error)
}

RetryableExecutor is the interface used for executing a closure and its fallback if the initial execution fails.

The interface is generic over type T which represents the return value of the closure.

func NewRetryableExecutor

func NewRetryableExecutor[T any](opts ...OptsFn) RetryableExecutor[T]

NewRetryableExecutor creates a new RetryableExecutor.

Jump to

Keyboard shortcuts

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