op

package
v0.5.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2023 License: MPL-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func StatusCounts

func StatusCounts(ops map[string]Op) (map[Status]int, error)

StatusCounts takes a slice of op references and returns a map containing sums of each Status

func WalkStatuses added in v0.5.0

func WalkStatuses(results map[string]any) map[Status]int

WalkStatuses performs a depth-first search of a tree of results and returns a map of status counts

Types

type Op

type Op struct {
	Identifier string                 `json:"-"`
	Result     map[string]any         `json:"result"`
	ErrString  string                 `json:"error"` // this simplifies json marshaling
	Error      error                  `json:"-"`
	Status     Status                 `json:"status"`
	Params     map[string]interface{} `json:"params,omitempty"`
	Start      time.Time              `json:"start"`
	End        time.Time              `json:"end"`
}

Op seeks information via its Runner then stores the results.

func New

func New(id string, result map[string]any, status Status, err error, params map[string]any, start time.Time, end time.Time) Op

New takes a runner its results, serializing it into an immutable Op struct.

func NewCancel added in v0.5.0

func NewCancel(id string, err error, params map[string]any, start time.Time) Op

NewCancel takes the minimum required fields to build and return an Op with status Canceled

func NewTimeout added in v0.5.0

func NewTimeout(id string, err error, params map[string]any, start time.Time) Op

NewTimeout takes the minimum required fields to build and return an Op with status Timeout

type Status

type Status string

Status describes the result of an operation.

const (
	// Success means all systems green
	Success Status = "success"

	// Fail means that we detected a known error and can conclusively say that the runner did not complete.
	Fail Status = "fail"

	// Unknown means that we detected an error and the result is indeterminate (e.g. some side effect like disk or
	// network may or may not have completed) or we don't recognize the error. If we don't recognize the error that's
	// a signal to improve the error handling to account for it.
	Unknown Status = "unknown"

	// Skip means that this Op was intentionally not run
	Skip Status = "skip"

	// Timeout means that an operation timed out during execution.
	Timeout Status = "timeout"

	// Canceled means that an operation was canceled during execution.
	Canceled Status = "canceled"
)

Jump to

Keyboard shortcuts

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