chain

package
v4.6.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Chain

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

Chain is a set of Runners that will be executed sequentially

func NewChain

func NewChain(retries int, retrySleep time.Duration) *Chain

NewChain creates a new chain. retries dictates how many times a Runner should be retried on error. retrySleep is how long to sleep before retrying a failed Runner

func (*Chain) AppendRunner

func (c *Chain) AppendRunner(cmd Runner) error

AppendRunner appends a Runner to the Chain

func (*Chain) Error

func (c *Chain) Error() error

Error returns the last error returned by a Runner

func (*Chain) ErrorRollback

func (c *Chain) ErrorRollback() error

ErrorRollback returns the last error returned by a Runner

func (*Chain) Execute

func (c *Chain) Execute() error

Execute runs the chain exactly once

func (*Chain) GetRunnerOutput

func (c *Chain) GetRunnerOutput(name string) interface{}

GetRunnerOutput returns the output from a Runner. It is valid to pass *Chain to a Runner. The Runner can then use *Chain.GetRunnerOutput(...) to reference the output of Runners that executed before them.

type Runner

type Runner interface {
	// Name is used for logging and locating the output of a previously run Runner
	Name() string
	// Run does the work and returns a value.  If error is returned the chain fails (after retries)
	Run() (interface{}, error)
	// Rollback is used to undo whatever Run() did
	Rollback() error
}

Runner describes a struct that can be run and rolled back

Jump to

Keyboard shortcuts

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