tasks

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 8 Imported by: ? 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 tasks holds the overmind's assigned-task model, seed-file loader, and the in-memory store that matches pending tasks to idle workers.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Sender

type Sender interface {
	Send(agentID string, env control.Envelope) error
}

Sender routes a control envelope to a named worker (satisfied by *supervisor.Server).

type Store

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

Store holds tasks in memory and matches pending ones to idle workers.

func NewStore

func NewStore(ts []Task, logger *log.Logger) *Store

NewStore wraps a loaded task slice.

func (*Store) Add

func (s *Store) Add(t Task) error

Add inserts a runtime task (plan-runner injection path). Same validation as LoadTasks; Status is forced to pending regardless of input.

func (*Store) AssignPending

func (s *Store) AssignPending(workers []supervisor.WorkerInfo, sender Sender)

AssignPending reconciles assignments against the current fleet snapshot, then sends an Assign for each pending task to an eligible idle worker. Called each status tick. Tasks assigned to a worker absent from the snapshot (died) are returned to pending for reassignment.

func (*Store) Get

func (s *Store) Get(id string) (Task, bool)

Get returns a copy of the task with the given id, if present.

func (*Store) HandleEvent

func (s *Store) HandleEvent(agentID string, ev control.Event)

HandleEvent updates task status from a worker's task_done / task_failed event. The event Detail begins with the task id (see the worker's OnTaskResult).

func (*Store) Remove

func (s *Store) Remove(id string) bool

Remove deletes the task with the given id. It reports whether a task was found and removed.

func (*Store) Snapshot

func (s *Store) Snapshot() []Task

Snapshot returns a copy of all tasks.

type Task

type Task struct {
	ID           string            `yaml:"id"`
	Script       string            `yaml:"script"`
	Params       map[string]string `yaml:"params"`
	RoleRequired string            `yaml:"role_required"`
	AgentID      string            `yaml:"agent_id"` // optional pin

	Status     TaskStatus `yaml:"-"`
	AssignedTo string     `yaml:"-"`
}

Task is one unit of assignable work.

func LoadTasks

func LoadTasks(path string) ([]Task, error)

LoadTasks parses the seed file at path, validating each task and defaulting Status to pending. Duplicate or empty ids, and missing script/role_required, are errors.

type TaskStatus

type TaskStatus string

TaskStatus is the lifecycle state of a task.

const (
	StatusPending  TaskStatus = "pending"
	StatusAssigned TaskStatus = "assigned"
	StatusRunning  TaskStatus = "running"
	StatusDone     TaskStatus = "done"
	StatusFailed   TaskStatus = "failed"
)

Jump to

Keyboard shortcuts

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