Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
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.
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 ¶
WithMaxRetryCount sets the max retry count.
Note that a default value is provided if the provided count is 0.
func WithRetryOnFallBackError ¶
WithRetryOnFallBackError sets the retryOnFallbackError flag.
func WithRetryTimeout ¶
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.