Documentation
¶
Overview ¶
Package jobs runs a change that takes longer than a request, or reaches another machine, as a job: one at a time, under the advisory lock for as long as it runs, with its output kept line by line for a page to stream.
A job is a person's confirmed command, run exactly as the CLI runs it. It can pause to ask the person something (rotate's "pasted the key?"), and it can be cancelled, which stops it between steps - never inside one, so a cancelled job never leaves a step half done. It holds the process's one change slot (mutation.Exclusive) from start to end, so no preview, change or other job interleaves with it.
Index ¶
Constants ¶
const ( Running = "running" Waiting = "waiting" // paused on a question Done = "done" Failed = "failed" Cancelled = "cancelled" )
States a job is in.
Variables ¶
var ErrCancelled = fmt.Errorf("cancelled: the steps before this one finished, and nothing after it ran: %w", mutation.ErrDeclined)
ErrCancelled is what a job's steps return once it has been cancelled. The history records the job as aborted.
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job struct {
// contains filtered or unexported fields
}
Job is one running or finished job.
func (*Job) Ask ¶
Ask pauses the job until the person answers, and reports their answer. A cancel answers no.
func (*Job) Step ¶
Step reports ErrCancelled once the job has been cancelled; a job calls it between its steps.
type Question ¶
Question is what a paused job is asking. Text is shown as is, for copying: rotate's staged public key.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry holds the jobs a server has started, and allows one to run at a time.
func (*Registry) Answer ¶
Answer answers the question a job is waiting on. It reports false when the job is not waiting.
func (*Registry) Cancel ¶
Cancel stops a job at its next step, answering no to a question it waits on.