Documentation
¶
Overview ¶
Package drives keeps `f10 drive` durable: a record per drive under the storage root, and a lease per task that one process holds while it acts on the task, so two drives, or a drive and `f10 finish`, never act on the same task at once.
Index ¶
Constants ¶
const Dir = "drives"
Dir is the drives directory under a storage root.
Variables ¶
This section is empty.
Functions ¶
func Create ¶
Create writes rec as the next numbered record, setting its number. The file is created exclusively, so two drives started at once get two.
Types ¶
type Answer ¶
type Answer struct {
Task string `yaml:"task"`
Skill string `yaml:"skill,omitempty"`
Text string `yaml:"text"`
At time.Time `yaml:"at"`
}
An Answer is one taken: by which task, at which skill, when.
type Holder ¶
type Holder struct {
PID int
Drive int // 0 for `f10 finish` itself
Watch bool // the daemon's watcher, finishing a task no drive owns
}
A Holder is who holds a lease, as its lock file names it.
type Lease ¶
type Lease struct {
// contains filtered or unexported fields
}
A Lease is a held lock, released by Release or by the process ending.
func Acquire ¶
Acquire takes key's lease for drive (0 for finish) under the storage root, without waiting on a holder: a held one is a HeldError naming it.
type Record ¶
type Record struct {
Number int `yaml:"number"`
Created time.Time `yaml:"created"`
Args []string `yaml:"args"` // the command line, --answer, --every and --foreground dropped
Tasks []Task `yaml:"tasks"`
Flow string `yaml:"flow,omitempty"`
Model string `yaml:"model,omitempty"` // the run-wide --model as typed
DriveFinish bool `yaml:"drive_finish"`
Cancelled *time.Time `yaml:"cancelled,omitempty"`
Session string `yaml:"session,omitempty"` // the session that created it, "" from a plain terminal
// Answers are given and not yet taken, by task id, "" for the bare one
Answers map[string]string `yaml:"answers,omitempty"`
Answered []Answer `yaml:"answered,omitempty"`
}
A Record is one drive, kept at <storage root>/drives/<n>.yaml: what it was started with, the answers given, and how each task ended.
func Find ¶
Find is the newest record started with args that is neither cancelled nor done, nil for none.
func Update ¶
Update applies change to record n under its own lock and writes it back through a rename, so a cancel and the drive's own writes never lose one another. It returns the record as written.
type Task ¶
type Task struct {
ID string `yaml:"id"` // as typed, a suffix included
Model string `yaml:"model,omitempty"` // its own :model as typed
Skill string `yaml:"skill,omitempty"` // in flight, "" for none
Outcome *Outcome `yaml:"outcome,omitempty"`
}
A Task is one task of a drive, as typed, and where it stands.