Documentation
¶
Overview ¶
Package drive drives an opted-in pursuit's plan: once a person or an agent's session has turned the loop on for a pursuit, the engine starts a run for each change the plan allows and never a second one, records a change as landed when version control shows it on the default branch, records a change whose PR was closed without merging as abandoned and asks a person, and never merges: it only reads the forge, and people keep the merge.
A per-pursuit timer ticks while the pursuit is driven and active; each tick writes at most one look, an intent that reads version control, the forge, the harness binding and the slots with no transaction open (internal/state/drive/look). The look's record then lands, stores, decides (internal/state/drive/decide) and starts in one transaction, from the store's own latest state, so two looks can never both start a change. A pursuit nobody opted in is never driven.
Index ¶
Constants ¶
const ( TickKind = "drive.tick" LookKind = "drive.look" )
The kinds this package registers: the per-pursuit timer, keyed by the pursuit's slug, and the intent each tick writes.
const ( StateLanded = "landed" StateRunning = "running" StateReady = "ready" StateHeld = "held" )
The states of a change in a Status.
Variables ¶
var ( ErrNotDriven = errors.New("pursuit not driven") ErrNotWaiting = errors.New("change not waiting on a person") )
The kinds of Refusal this package adds to work's and the plan's. Each is a *work.Refusal, so the API replies bad_request with its message.
Functions ¶
Types ¶
type AgainIn ¶
type AgainIn struct {
Pursuit, Change, By string
}
AgainIn is a person's answer for a change the loop holds for them: run it again. By is the person; nothing answers on a person's behalf.
type ChangeStatus ¶
type ChangeStatus struct {
Name, State, Reason string
}
ChangeStatus is one change of the plan as the loop sees it: landed, running (it has an unended run), ready, or held with the reason decide gives.
type DriveIn ¶
type DriveIn struct {
Pursuit, By string
}
DriveIn turns the loop on for a pursuit, saying who turned it on.
type Options ¶
type Options struct {
Env []string
NewForge func(root string) forge.Forge
Bind func(root string) (staterun.StartIn, error)
Live func(exceptStore string) int
Slots func() int
Every, ForgeEvery time.Duration
}
Options configures the loop. Env is the environment git runs in. NewForge gives the forge of a repo root; nil means no forge, so no PR's state is ever seen. Bind returns the harness binding's level and command lines for a repo root, with the pursuit and change left empty, or an error saying why no run can start there; nil means nothing can be started, and each look's result says so. Live counts the runs the engine holds for stores other than the one named; nil counts 0. Slots is how many runs may be live at once on this machine; nil means 1. Every is the tick's cadence and ForgeEvery the forge's cadence and first backoff; 0 is 1 minute for each.
type Status ¶
type Status struct {
Pursuit string
Driven bool
By string
At time.Time
Already bool
Changes []ChangeStatus
}
Status is a pursuit as the loop sees it: whether it is driven, by whom and since when, and each change of its plan in plan order. Already is set by Drive when the pursuit was driven before the call. It is read from the store only, with every slot counted as free: ready means the next look starts the change if a slot is free and the harness binding loads, not that a run is sure to start. A pursuit that is not driven shows what the loop would see.
func Again ¶
Again records a person's answer that a held change may be run again, as one command: it ends the change's open abandoned items with who answered, stamps the change with now and the number of its newest run, so only a run after the answer counts as new, and appends the event change.again. It starts nothing itself: the next look does. An empty By, an unknown pursuit, a change not in the plan, a pursuit that is not driven and a change that is not waiting on a person (it has no unanswered abandoned item, and its newest run did not end without a PR since the last answer) are refused.
func Drive ¶
Drive turns the loop on for an active pursuit that has a plan, as one command: it records who and when, appends the event pursuit.driven and sets the pursuit's tick due now. An unknown pursuit, an empty By, a pursuit that is done or stopped and one with no plan are refused. A pursuit already driven is no error and writes nothing, and the Status says Already; if it is active and its tick is missing, the tick is set again. If the loop's kinds are not registered the command fails and nothing is stored.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package decide chooses which changes of a plan to start now and says why it holds each of the others.
|
Package decide chooses which changes of a plan to start now and says why it holds each of the others. |
|
Package look is the reading half of one look of the engine's loop at a driven pursuit: with no transaction open it reads which changes have landed from version control, asks the forge whether each run's PR is open, merged or closed when the forge's next time has come, loads the harness binding and reads the machine's slots, and returns all of it as one result.
|
Package look is the reading half of one look of the engine's loop at a driven pursuit: with no transaction open it reads which changes have landed from version control, asks the forge whether each run's PR is open, merged or closed when the forge's next time has come, loads the harness binding and reads the machine's slots, and returns all of it as one result. |