chain

package
v4.7.0+incompatible Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 3 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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