package exec

import "github.com/centrifuge/go-substrate-rpc-client/v4/registry/exec"

Index

Variables

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

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 NewRetryableExecutorMockT

type NewRetryableExecutorMockT interface {
	mock.TestingT
	Cleanup(func())
}

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.

type RetryableExecutorMock

type RetryableExecutorMock[T interface{}] struct {
	mock.Mock
}

RetryableExecutorMock is an autogenerated mock type for the RetryableExecutor type

func NewRetryableExecutorMock

func NewRetryableExecutorMock[T interface{}](t NewRetryableExecutorMockT) *RetryableExecutorMock[T]

NewRetryableExecutorMock creates a new instance of RetryableExecutorMock. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations.

func (*RetryableExecutorMock[T]) ExecWithFallback

func (_m *RetryableExecutorMock[T]) ExecWithFallback(execFn func() (T, error), fallbackFn func() error) (T, error)

ExecWithFallback provides a mock function with given fields: execFn, fallbackFn

Source Files

exec.go exec_mock.go

Version
v4.2.1 (latest)
Published
Dec 5, 2023
Platform
linux/amd64
Imports
5 packages
Last checked
2 weeks ago

Tools for package owners.