executor

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Apr 10, 2026 License: MPL-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountErrors

func CountErrors(results []Result) int

CountErrors returns the number of failed results.

func ErrorSummary

func ErrorSummary(results []Result) []string

ErrorSummary returns a summary of all errors.

Types

type Executor

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

Executor runs tasks in parallel with bounded concurrency.

func New

func New(parallelism int, quiet bool, w io.Writer) *Executor

New creates a new executor with the given parallelism.

func (*Executor) Run

func (e *Executor) Run(ctx context.Context, tasks []Task) []Result

Run executes all tasks with bounded concurrency and returns results in order.

func (*Executor) RunSimple

func (e *Executor) RunSimple(ctx context.Context, repoNames []string, fn func(ctx context.Context, name string) error) []Result

RunSimple executes a simple function for each repo name.

type Result

type Result struct {
	// RepoName is the name of the repo this result belongs to.
	RepoName string `json:"repo"`
	// Success indicates if the task succeeded.
	Success bool `json:"success"`
	// Output contains any output from the task.
	Output string `json:"output,omitempty"`
	// Error contains the error message if the task failed.
	Error string `json:"error,omitempty"`
	// Data holds arbitrary result data.
	Data any `json:"data,omitempty"`
}

Result represents the outcome of a task execution.

type Task

type Task struct {
	RepoName string
	Fn       TaskFunc
}

Task represents a unit of work to execute.

type TaskFunc

type TaskFunc func(ctx context.Context) (*Result, error)

TaskFunc is a function that performs work for a single repo.

Jump to

Keyboard shortcuts

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