tools: go.uber.org/tools/lib/parallel Index | Files

package parallel

import "go.uber.org/tools/lib/parallel"

Index

Package Files

cmd_controller.go event.go event_type.go exec_cmd.go parallel.go runner.go semaphore.go

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
)

type Cmd Uses

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.

func ExecCmd Uses

func ExecCmd(cmd *exec.Cmd) Cmd

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

func ExecCmds Uses

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

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

type Event Uses

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 Uses

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 Uses

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

MarshalJSON marshals the EventType to JSON.

func (EventType) MarshalText Uses

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

MarshalText marshals the EventType to text.

func (EventType) String Uses

func (e EventType) String() string

String returns a string representation of the EventType.

func (*EventType) UnmarshalJSON Uses

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

UnmarshalJSON unmarshals the EventType from JSON.

func (*EventType) UnmarshalText Uses

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

UnmarshalText unmarshals the EventType from text.

type Runner Uses

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 Uses

func NewRunner(options ...RunnerOption) Runner

NewRunner returns a new Runner.

type RunnerOption Uses

type RunnerOption func(*runner)

RunnerOption is an option for a new Runner.

func WithClock Uses

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

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

func WithEventHandler Uses

func WithEventHandler(eventHandler func(*Event)) RunnerOption

WithEventHandler returns a RunnerOption that will use the given EventHandler.

func WithFastFail Uses

func WithFastFail() RunnerOption

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

func WithMaxConcurrentCmds Uses

func WithMaxConcurrentCmds(maxConcurrentCmds int) RunnerOption

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

Package parallel imports 12 packages (graph) and is imported by 2 packages. Updated 2019-04-30. Refresh now. Tools for package owners.