run

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 7, 2021 License: GPL-3.0 Imports: 5 Imported by: 0

Documentation

Overview

Package run defines metadata about transform script execution

Index

Examples

Constants

View Source
const (
	// RSWaiting indicates a script/step that has yet to start
	RSWaiting = Status("waiting")
	// RSRunning indicates a script/step is currently executing
	RSRunning = Status("running")
	// RSSucceeded indicates a script/step has completed without error
	RSSucceeded = Status("succeeded")
	// RSFailed indicates a script/step completed & exited when an unexpected error
	// occured
	RSFailed = Status("failed")
	// RSUnchanged indicates a script completed but no changes were found
	// since the last version of the script succeeded
	RSUnchanged = Status("unchanged")
	// RSSkipped indicates a script/step was not executed
	RSSkipped = Status("skipped")
)

Variables

This section is empty.

Functions

func NewID

func NewID() string

NewID creates a run identifier

Example
myString := "SomeRandomStringThatIsLong-SoYouCanCallItAsMuchAsNeeded..."
SetIDRand(strings.NewReader(myString))
a := NewID()
SetIDRand(strings.NewReader(myString))
b := NewID()

fmt.Printf("a:  %s\nb:  %s\neq: %t", a, b, a == b)
Output:

a:  536f6d65-5261-4e64-af6d-537472696e67
b:  536f6d65-5261-4e64-af6d-537472696e67
eq: true

func SetIDRand

func SetIDRand(r io.Reader)

SetIDRand sets the random reader that NewID uses as a source of random bytes passing in nil will default to crypto.Rand. This can be used to make ID generation deterministic for tests. eg:

myString := "SomeRandomStringThatIsLong-SoYouCanCallItAsMuchAsNeeded..."
run.SetIDRand(strings.NewReader(myString))
a := NewID()
run.SetIDRand(strings.NewReader(myString))
b := NewID()

Types

type State

type State struct {
	ID        string       `json:"id"`
	Number    int          `json:"number"`
	Status    Status       `json:"status"`
	Message   string       `json:"message"`
	StartTime *time.Time   `json:"startTime"`
	StopTime  *time.Time   `json:"stopTime"`
	Duration  int          `json:"duration"`
	Steps     []*StepState `json:"steps"`
}

State is a passable, cachable data structure that describes the execution of a transform. State structs can act as a sink of transform events, collapsing the state transition of multiple transform events into a single structure

func NewState

func NewState(id string) *State

NewState is a simple constructor to remind package consumers that state structs must be initialized with an identifier to act as a sink of transform events

func (*State) AddTransformEvent

func (rs *State) AddTransformEvent(e event.Event) error

AddTransformEvent alters state based on a given event

type Status

type Status string

Status enumerates all possible execution states of a transform script or step within a script, in relation to the current time. Scripts & steps that have completed are broken into categories based on exit state

type StepState

type StepState struct {
	Name      string        `json:"name"`
	Category  string        `json:"category"`
	Status    Status        `json:"status"`
	StartTime *time.Time    `json:"startTime"`
	StopTime  *time.Time    `json:"stopTime"`
	Duration  int           `json:"duration"`
	Output    []event.Event `json:"output"`
}

StepState describes the execution of a transform step

func NewStepStateFromEvent

func NewStepStateFromEvent(e event.Event) (*StepState, error)

NewStepStateFromEvent constructs StepState from an event

Jump to

Keyboard shortcuts

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