common

package
v0.0.0-...-6ac7c4f Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2024 License: Apache-2.0 Imports: 7 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDefer = errors.New("deferred")

ErrDefer that implements `error` but safe to ignore.

Functions

func CatchPanic

func CatchPanic(ctx context.Context, e Executor) error

CatchPanic wraps the executor with panic handler

func Dryrun

func Dryrun(ctx context.Context) bool

Dryrun returns true if the current context is dryrun.

func NewWarning

func NewWarning(format string, args ...interface{}) error

NewWarning returns a warning

func WithDryrun

func WithDryrun(ctx context.Context, dryrun bool) context.Context

WithDryrun adds a value to the context for dryrun.

Types

type Conditional

type Conditional func(ctx context.Context) bool

Conditional define contract for the conditional predicate

func (Conditional) Not

func (c Conditional) Not() Conditional

Not return an inverted conditional

type Executor

type Executor func(ctx context.Context) error

Executor define contract for the steps of a workflow

func NewConditionalExecutor

func NewConditionalExecutor(conditional Conditional, trueExecutor Executor, falseExecutor Executor) Executor

NewConditionalExecutor creates a new executor based on conditions

func NewDebugExecutor

func NewDebugExecutor(format string, args ...interface{}) Executor

NewDebugExecutor is an executor that logs messages

func NewErrorExecutor

func NewErrorExecutor(err error) Executor

NewErrorExecutor creates a new executor that always errors out

func NewInfoExecutor

func NewInfoExecutor(format string, args ...interface{}) Executor

NewInfoExecutor is an executor that logs messages

func NewParallelExecutor

func NewParallelExecutor(parallel int, executors ...Executor) Executor

NewParallelExecutor creates a new executor from a parallel of other executors

func NewPipelineExecutor

func NewPipelineExecutor(executors ...Executor) Executor

NewPipelineExecutor creates a new executor from a series of other executors

func NewWarningExecutor

func NewWarningExecutor(format string, args ...interface{}) Executor

NewWarningExecutor is an executor that returns a warning

func (Executor) CatchPanic

func (e Executor) CatchPanic() Executor

CatchPanic wraps the executor with panic handler

func (Executor) DeferUntil

func (e Executor) DeferUntil(ready ReadyFunc) Executor

DeferUntil a ReadyFunc is ready

func (Executor) Finally

func (e Executor) Finally(finally Executor) Executor

Finally adds an executor to run after other executor

func (Executor) If

func (e Executor) If(conditional Conditional) Executor

If only runs this executor if conditional is true

func (Executor) IfBool

func (e Executor) IfBool(conditional bool) Executor

IfBool only runs this executor if conditional is true

func (Executor) IfNot

func (e Executor) IfNot(conditional Conditional) Executor

IfNot only runs this executor if conditional is true

func (Executor) Then

func (e Executor) Then(then Executor) Executor

Then runs another executor if this executor succeeds

func (Executor) TraceRegion

func (e Executor) TraceRegion(regionType string) Executor

TraceRegion wraps the executor with a trace

func (Executor) WrapWith

func (e Executor) WrapWith(wrappers ...Wrapper) Executor

WrapWith returns a new Executor that applies the provided [Wrapper]s to this Executor

type ReadyFunc

type ReadyFunc func() (bool, error)

ReadyFunc determines when an executor is ready to run

type Warning

type Warning struct {
	Message string
}

Warning that implements `error` but safe to ignore.

func (Warning) Error

func (w Warning) Error() string

Error the contract for error

type Wrapper

type Wrapper func(ctx context.Context, e Executor) error

Wrapper is a type that performs activities before and/or after an executor runs

func (Wrapper) Wrap

func (w Wrapper) Wrap(e Executor) Executor

Wrap returns a new Executor that applies this Wrapper to the provided Executor

Jump to

Keyboard shortcuts

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