executor

package
v1.0.2-0...-84e4af3 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const LogStepKey = "step"

Variables

View Source
var Attempts = retry.Attempts
View Source
var BackOffDelay = retry.BackOffDelay
View Source
var Delay = retry.Delay
View Source
var DelayType = retry.DelayType
View Source
var FixedDelay = retry.FixedDelay
View Source
var OnRetry = retry.OnRetry

Functions

func Do

func Do(fn retry.RetryableFunc, opts ...retry.Option) error

Types

type CleanupMode

type CleanupMode string

CleanupMode says how runner should execute cleanup

const (
	// CleanupModeNo - Don't execute cleanup
	CleanupModeNo CleanupMode = "no"
	// CleanupModeOnly - Don't run Steps, only cleanup
	CleanupModeOnly CleanupMode = "only"
	// Execute both Steps and cleanup
	CleanupModeYes CleanupMode = "yes"
	// Execute Steps. If Steps fail then run cleanup. Keep resources in case of success
	CleanupModeOnErrorOnly   CleanupMode = "onErrorOnly"
	CleanupModeOnSuccessOnly CleanupMode = "onSuccessOnly"
)

func (*CleanupMode) Set

func (m *CleanupMode) Set(v string) error

Set implements pflag.Value.Set

func (CleanupMode) String

func (m CleanupMode) String() string

String implements pflag.Value.String

func (CleanupMode) Type

func (m CleanupMode) Type() string

Type implements pflag.Value.Type

type Option

type Option = retry.Option

type Parallelized

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

func NewParallelRunner

func NewParallelRunner(logf *logrus.Entry, name string, steps ...Step) *Parallelized

func (*Parallelized) Cleanup

func (p *Parallelized) Cleanup() error

func (*Parallelized) Name

func (p *Parallelized) Name() string

func (*Parallelized) OnError

func (p *Parallelized) OnError() error

func (*Parallelized) Run

func (p *Parallelized) Run() error

type Retried

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

func Retry

func Retry(steps ...Step) *Retried

func (*Retried) Cleanup

func (r *Retried) Cleanup() error

func (*Retried) Name

func (r *Retried) Name() string

func (*Retried) Run

func (r *Retried) Run() error

func (*Retried) WithRetryOptions

func (r *Retried) WithRetryOptions(options ...Option) *Retried

type Runner

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

Runner executes Steps in safe manner

func NewRunner

func NewRunner(opts ...RunnerOption) *Runner

NewRunner returns new runner

func (*Runner) AddFlags

func (r *Runner) AddFlags(set *pflag.FlagSet)

AddFlags add CLI flags so user may control runner behaviour easily

func (*Runner) Cleanup

func (r *Runner) Cleanup(steps []Step)

Cleanup cleans up given steps in reverse order

func (*Runner) Execute

func (r *Runner) Execute(step Step) error

Execute behavior is based on chose cleanup method. It is intended to be used with AddFlags

func (*Runner) Run

func (r *Runner) Run(step Step, skipCleanup bool) error

Run executes Steps in specified order. If skipCleanup is false it also executes Step.Cleanup in reverse order starting from last executed step

type RunnerOption

type RunnerOption func(runner *Runner)

func WithCleanupDefault

func WithCleanupDefault(mode CleanupMode) RunnerOption

func WithLogger

func WithLogger(logger *logrus.Logger) RunnerOption

type SerialRunner

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

func NewSerialTestRunner

func NewSerialTestRunner(log *logrus.Entry, name string, steps ...Step) *SerialRunner

func (SerialRunner) Cleanup

func (s SerialRunner) Cleanup() error

func (SerialRunner) Name

func (s SerialRunner) Name() string

func (SerialRunner) OnError

func (s SerialRunner) OnError() error

func (*SerialRunner) Run

func (s *SerialRunner) Run() error

type Step

type Step interface {
	// Name returns Name of the step
	Name() string
	// Run executes the step
	Run() error
	// Cleanup removes all resources that may possibly created by the step
	Cleanup() error
	// OnError is callback in case of error
	OnError() error
}

Step represents a single action in test scenario

Jump to

Keyboard shortcuts

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