Documentation
¶
Overview ¶
Package taskrunner schedules and executes tasks with dependency resolution. It performs topological sorting to determine execution order, tracks task status, and supports self-healing retries for failed tasks.
Index ¶
- Constants
- type ExecuteFunc
- type Runner
- func (r *Runner) AllDone() bool
- func (r *Runner) ExecuteGroup(ctx context.Context, group []int, fn ExecuteFunc) error
- func (r *Runner) Results() map[int]TaskResult
- func (r *Runner) Schedule() ([][]int, error)
- func (r *Runner) Status(id int) types.TaskStatus
- func (r *Runner) Summary() (total, done, failed, skipped int)
- func (r *Runner) Tasks() []types.Task
- type TaskResult
Constants ¶
const MaxParallelTasks = types.DefaultMaxParallelTasks
MaxParallelTasks is the default maximum number of tasks to execute concurrently within a group. Deprecated: use types.DefaultMaxParallelTasks or Runner.MaxParallel instead.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ExecuteFunc ¶
type ExecuteFunc func(ctx context.Context, task types.Task) TaskResult
ExecuteFunc is the function called to execute a single task.
type Runner ¶
type Runner struct {
OnTaskStart func(task types.Task)
OnTaskUpdate func(task types.Task, status string)
// TaskTimeout is the per-task timeout. Zero means no timeout.
// Defaults to 30 minutes to match the Bash tool's default timeout.
TaskTimeout time.Duration
// MaxRetries is the number of retry attempts for failed tasks. Default 0.
MaxRetries int
// MaxParallel is the maximum number of tasks to execute concurrently within a group.
// Zero means use DefaultMaxParallelTasks (4).
MaxParallel int
// contains filtered or unexported fields
}
Runner schedules and executes tasks with dependency resolution.
func (*Runner) AllDone ¶
AllDone returns true when all tasks are done, skipped, failed, or unrecoverable.
func (*Runner) ExecuteGroup ¶
ExecuteGroup runs all tasks in the group concurrently with bounded parallelism. Dependencies must have been completed in prior groups. The provided ctx is used as the parent context for all tasks, ensuring that cancellation (e.g. from TUI shutdown) propagates to running tasks.
func (*Runner) Results ¶
func (r *Runner) Results() map[int]TaskResult
Results returns a copy of all task results.
func (*Runner) Schedule ¶
Schedule performs topological sort and returns execution groups. Each group contains task IDs that are ready to execute (dependencies met). In V1, tasks within a group run sequentially.
func (*Runner) Status ¶
func (r *Runner) Status(id int) types.TaskStatus
Status returns the current status of a task.