dispatch

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 9 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 dispatch decides which planned task starts now: the scheduler's rules, in plain Go, apart from the store and the workers. A pass reads a Situation (the tasks, the wishes, the projects, the machine) and gives a Decision for each planned task: start it, let it wait with its reason, or fail it. The harness acts on the decisions; the dispatch bench (internal/dispatch/bench) feeds it cases written by hand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Light

func Light(t *planv1.Task) bool

Light tells whether the task takes no slot of the machine: a watcher, or a question worker.

func Overlap

func Overlap(a, b []string) bool

Overlap tells whether two sets of write scopes share a path: one names the other, or a folder holding it. No scope is the whole folder. Case is ignored, as on macOS and Windows.

func Planned

func Planned(t *planv1.Task) bool

Planned tells whether Djinn starts the task by itself, once it is ready: a task planned on this machine, or one whose worker Djinn resumes (cut short by a restart, or by its provider's usage limit). An azima never is: no worker runs it.

func QuestionWorker

func QuestionWorker(t *planv1.Task) bool

QuestionWorker tells whether Djinn started the task on a question (Task.role): it reads and runs djinn's commands, no build nor gate, so it takes no slot and holds no write scope; an agent all the same, it waits while the machine is under pressure or its memory would not hold it.

func Resuming

func Resuming(t *planv1.Task) bool

Resuming tells whether the task is one Djinn resumes.

func ScopeText

func ScopeText(scopes []string) string

ScopeText writes write scopes for a person.

func Watcher

func Watcher(t *planv1.Task) bool

Watcher tells whether the task is a watcher: a command, no agent. It takes no slot and writes nothing, so neither the machine nor the write scopes hold it, and it holds no other task.

Types

type Decision

type Decision struct {
	Task *planv1.Task
	// Why it waits.
	Why string
	// Why it never will start: it fails.
	Failed string
	// It waits for a dependency's work to be committed into the wish's integration branch: the integration commits
	// that work at once.
	Commit bool
}

Decision is what a pass decides for one planned task. Why and Failed both empty: it starts now.

type Machine

type Machine struct {
	// Slots is the most workers that run at once, and Rule how it was decided.
	Slots int
	Rule  string
	// Pressure says why the machine is under pressure, "" when it is not: no worker starts then.
	Pressure string
	// Running is the number of workers that run now.
	Running int
	// Gates is the number of gates held outside the running workers: each takes a slot.
	Gates int
	// Available is the memory available to new programs, in bytes; 0 when unknown, and then the memory holds no
	// worker back. Policy weighs it against what a worker of the task's provider typically takes
	// (machine.Policy.WorkerRoom).
	Available uint64
	Policy    machine.Policy
}

Machine is what the machine allows now.

type Situation

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

Situation is what a pass knows: every task, every wish, which projects are in Git, and the machine. Its zero value knows nothing and limits nothing; New fills it.

func New

func New(tasks []*planv1.Task, wishes []*planv1.Wish, git map[string]bool, machine *Machine) *Situation

New is the situation of tasks and wishes, all of them as the store lists them (oldest first), the projects in Git being git (a project not in it is not), and machine what the machine allows (nil: nothing limits).

func (*Situation) At

func (s *Situation) At(now time.Time) *Situation

At sets the time the situation is read at, which a usage limit's reset is compared with: the harness's clock.

func (*Situation) Blocker

func (s *Situation) Blocker(t *planv1.Task) (why, failed string)

Blocker says why the task cannot start now (why), or why it never will (failed); both empty when it can start. Its wish must be active (not paused nor granted); then come the dependencies, its provider's usage limit, the write scopes, and the machine; a watcher only waits for its wish and its dependencies, a question worker for the machine's pressure and memory too. A wish the situation does not know does not hold the task.

func (*Situation) Order

func (s *Situation) Order() []*planv1.Task

Order is the planned tasks: the ones Djinn resumes first, as they ran before; then by the rank of their wish, then the oldest first. The tasks of a wish that is not active come last; Blocker keeps them waiting.

func (*Situation) Pass

func (s *Situation) Pass() []Decision

Pass decides for every planned task, the first wish of the rank first, then the oldest: each task it starts counts as writing and takes a slot for the ones after it.

func (*Situation) Start

func (s *Situation) Start(t *planv1.Task)

Start counts the task as started: it writes in its project, takes a slot and memory. A question worker only takes memory; a watcher, nothing.

Directories

Path Synopsis
Package bench is the dispatch bench (T07): dispatch situations written as data, each with the decision expected by hand, and what a contender decides for each.
Package bench is the dispatch bench (T07): dispatch situations written as data, each with the decision expected by hand, and what a contender decides for each.

Jump to

Keyboard shortcuts

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