Documentation ¶
Overview ¶
Package runner provides implementations for running commands in different environments.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BatchRunner ¶
type BatchRunner struct {
// contains filtered or unexported fields
}
BatchRunner allows many tasks to be run in paralell using a Runner. BatchRunner will give every process the same stderr of your choice but will save the contents of every stdout for later debugging.
func NewBatchRunner ¶
func NewBatchRunner(ctx context.Context, runner Runner, maxBatchSize int) *BatchRunner
NewBatchRunner creates a BatchRunner that can use runner to run many jobs in paralell. At most maxBatchSize jobs will be active at once. Enqueue will block when maxBatchSize is exceeded. When ctx is Done, all jobs will terminate without error.
func (*BatchRunner) Enqueue ¶
func (b *BatchRunner) Enqueue(command []string, stdout, stderr io.Writer, closers ...func())
Enqueue is similair to Run in Runner except that it's async. The call returns immediately and the enqueued command starts running. If however the maximum batch size has been reached Enqueue will block until a new job opens up.
func (*BatchRunner) Wait ¶
func (b *BatchRunner) Wait() error
Wait blocks on all previouslly Enqueued tasks to finish. It is invalid for Enqueue to be called after Wait is called.
type Runner ¶
Runner defines the interface for running commands by many means such as via SSH or via Shell or serial or some other such means.
type SubprocessRunner ¶
type SubprocessRunner struct { // Dir is the working directory of the subprocesses; if unspecified, that // of the current process will be used. Dir string // Env is the environment of the subprocess, following the usual convention of a list of // strings of the form "<environment variable name>=<value>". Env []string }
SubprocessRunner is a Runner that runs commands as local subprocesses.