runner

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package runner runs an operation across targets with bounded concurrency.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Err

func Err(outcomes []Outcome) error

Err returns an error when any target failed, so the process can exit non-zero.

func Note

func Note(detail string) error

Note returns an error that marks the target as successful and records detail on its outcome.

func Skip

func Skip(reason string) error

Skip returns an error that marks the target as skipped rather than failed.

Types

type Func

type Func func(ctx context.Context, t discover.Target) error

Func is the operation run for each target. Return Skip(reason) when the target has nothing to do.

type Outcome

type Outcome struct {
	Target discover.Target
	Status Status
	// Reason explains a skipped target.
	Reason string
	// Detail is an optional note on a successful target.
	Detail string
	// Err is set for failed targets.
	Err error
}

Outcome is the result of running the operation for one target.

func Run

func Run(ctx context.Context, targets []discover.Target, jobs int, fn Func) []Outcome

Run calls fn for every target, at most jobs at a time (jobs <= 0 means all at once), and returns one Outcome per target in input order. Targets not started before ctx is cancelled fail with the context error.

type Status

type Status int

Status is the result category of one target.

const (
	OK Status = iota
	Skipped
	Failed
)

Jump to

Keyboard shortcuts

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