Documentation ¶
Index ¶
Constants ¶
const DefaultFastFail = false
DefaultFastFail is the default value for fast fail.
Variables ¶
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 )
Functions ¶
This section is empty.
Types ¶
type Cmd ¶
type Cmd interface { fmt.Stringer // 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.
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. EventTypeCmdStarted // EventTypeCmdFinished says that a command finished. EventTypeCmdFinished // EventTypeFinished says that the runner finished. EventTypeFinished )
func (EventType) MarshalJSON ¶
MarshalJSON marshals the EventType to JSON.
func (EventType) MarshalText ¶
MarshalText marshals the EventType to text.
func (*EventType) UnmarshalJSON ¶
UnmarshalJSON unmarshals the EventType from JSON.
func (*EventType) UnmarshalText ¶
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.
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.