runner

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 11, 2025 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Result

type Result struct {
	Args   []string
	Stdout []byte
	Stderr []byte
	Error  error
}

Result contains the output of a command execution

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner is a helper to run commands in a queue, the commands are immediately exectuded in a goroutine as they are enqueued. The runner can be stopped by calling Cancel.

func New

func New(inCtx context.Context, workers int) *Runner

New creates a new Runner with the given number of workers. If workers is 0, the number of workers will be the number of available CPUs.

func (*Runner) Cancel

func (r *Runner) Cancel()

func (*Runner) Enqueue

func (r *Runner) Enqueue(task *Task)

func (*Runner) Results

func (r *Runner) Results(task *Task) *Result

type Task

type Task struct {
	Args        []string `json:"args"`
	LimitStderr int      `json:"-"`
}

Task is a command to be executed

func NewTask

func NewTask(args ...string) *Task

NewTask creates a new Task

func NewTaskWithLimitedStderr

func NewTaskWithLimitedStderr(limit int, args ...string) *Task

NewTaskWithLimitedStderr creates a new Task with a hard-limit on the stderr output

func (*Task) Run

func (t *Task) Run(ctx context.Context) *Result

Run executes the command and returns the result

func (*Task) String

func (t *Task) String() string

Jump to

Keyboard shortcuts

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