Version: v0.0.0-...-2cfd321 Latest Latest

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

Go to latest
Published: Jun 18, 2019 License: MIT Imports: 12 Imported by: 2




View Source
const DefaultFastFail = false

DefaultFastFail is the default value for fast fail.


View Source
var (
	// DefaultMaxConcurrentCmds is the default value for the maximum
	// number of concurrent commands.
	DefaultMaxConcurrentCmds = runtime.NumCPU()
	// DefaultEventHandler is the default Event handler.
	DefaultEventHandler = logEvent
	// DefaultClock is the default function to use as a clock.
	DefaultClock = time.Now


This section is empty.


type Cmd

type Cmd interface {

	// Start the command.
	Start() error
	// Wait for the command to complete and block.
	Wait() error
	// Kill the command.
	Kill() error

Cmd is a command to run.

func ExecCmd

func ExecCmd(cmd *exec.Cmd) Cmd

ExecCmd returns a new Cmd for the given exec.Cmd.

func ExecCmds

func ExecCmds(cmds []*exec.Cmd) []Cmd

ExecCmds returns a slice of Cmds for the given exec.Cmds.

type Event

type Event struct {
	Type   EventType              `json:"type,omitempty" yaml:"type,omitempty"`
	Time   time.Time              `json:"time,omitempty" yaml:"time,omitempty"`
	Fields map[string]interface{} `json:"fields,omitempty" yaml:"fields,omitempty"`
	Error  string                 `json:"error,omitempty" yaml:"error,omitempty"`

Event is an event that happens during the runner's Run call.

type EventType

type EventType int

EventType is an event type during the runner's run call.

const (
	// EventTypeStarted says that the runner started.
	EventTypeStarted EventType = iota + 1
	// EventTypeCmdStarted says that a command started.
	// EventTypeCmdFinished says that a command finished.
	// EventTypeFinished says that the runner finished.

func (EventType) MarshalJSON

func (e EventType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the EventType to JSON.

func (EventType) MarshalText

func (e EventType) MarshalText() ([]byte, error)

MarshalText marshals the EventType to text.

func (EventType) String

func (e EventType) String() string

String returns a string representation of the EventType.

func (*EventType) UnmarshalJSON

func (e *EventType) UnmarshalJSON(data []byte) error

UnmarshalJSON unmarshals the EventType from JSON.

func (*EventType) UnmarshalText

func (e *EventType) UnmarshalText(data []byte) error

UnmarshalText unmarshals the EventType from text.

type Runner

type Runner interface {
	// Run the commands.
	// Return error if there was an initialization error, or any of
	// the running commands returned with a non-zero exit code.
	Run(cmds []Cmd) error

Runner runs the commands.

func NewRunner

func NewRunner(options ...RunnerOption) Runner

NewRunner returns a new Runner.

type RunnerOption

type RunnerOption func(*runner)

RunnerOption is an option for a new Runner.

func WithClock

func WithClock(clock func() time.Time) RunnerOption

WithClock returns a RunnerOption that will make the Runner use the given Clock.

func WithEventHandler

func WithEventHandler(eventHandler func(*Event)) RunnerOption

WithEventHandler returns a RunnerOption that will use the given EventHandler.

func WithFastFail

func WithFastFail() RunnerOption

WithFastFail returns a RunnerOption that will return error fun Run as soon as one of the commands fails.

func WithMaxConcurrentCmds

func WithMaxConcurrentCmds(maxConcurrentCmds int) RunnerOption

WithMaxConcurrentCmds returns a RunnerOption that will make the Runner only run maxConcurrentCmds at once, or unlimited if 0.

Jump to

Keyboard shortcuts

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