parallel

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Pool

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

Pool manages parallel task execution using isolated git worktrees.

func NewPool

func NewPool(repoDir string, baseBranch string, maxWorkers int) *Pool

NewPool creates a parallel execution pool rooted at the given git repo. maxWorkers caps the number of concurrent goroutines; if <= 0 it defaults to 4.

func (*Pool) AddTask

func (p *Pool) AddTask(description string) *Task

AddTask queues a task for parallel execution and returns it. The task ID and branch name are auto-generated.

func (*Pool) Cleanup

func (p *Pool) Cleanup() error

Cleanup removes all worktrees created by this pool. It is idempotent.

func (*Pool) Results

func (p *Pool) Results() []*Task

Results returns all tasks (completed, failed, or pending).

func (*Pool) Run

func (p *Pool) Run(ctx context.Context, workFn func(ctx context.Context, worktreePath string, task *Task) (string, error)) error

Run executes all queued tasks in parallel, each in its own git worktree. workFn receives the worktree path and task, and returns a result summary. Tasks that fail do not prevent other tasks from completing.

type Status

type Status int

Status represents the current state of a parallel task.

const (
	StatusPending Status = iota
	StatusRunning
	StatusDone
	StatusFailed
)

func (Status) String

func (s Status) String() string

String returns a human-readable label for the status.

type Task

type Task struct {
	ID           string
	Description  string
	Branch       string // auto-generated branch name: hawk-parallel/{ID}
	WorktreePath string // filesystem path to the worktree
	Status       Status
	Error        error
	Result       string // summary of what was done
}

Task represents a single unit of work that will execute in its own git worktree.

Jump to

Keyboard shortcuts

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