Documentation
¶
Overview ¶
Package run is the two things a run is in the store: its head, which says where it stands, and its record, which is everything that happened to it; and the messages and receipts that pass between a client and the controller about it.
Index ¶
- Constants
- Variables
- func MovedNote(message, to string) string
- func Others(id string) error
- func Reads(run string, head *Head, client string, listed bool) bool
- func TimerOf(wake string) (string, bool)
- func TreeVersion(hashes map[string]string) string
- func UndeliveredNote(message string) string
- type Above
- type Answer
- type Arrived
- type Ask
- type CallReceipt
- type CallResult
- type Cause
- type Emit
- type EmitNote
- type Emitted
- type Going
- type Head
- type Heard
- type HookRef
- type HooksAbove
- type Job
- type Listed
- type Message
- type Receipt
- type Recorded
- type Result
- type SendNote
- type Setting
- type SourceFile
- type Start
- type State
- type Step
- func Current(ctx context.Context, s store.Store, ctl identity.Card, id *identity.Identity, ...) (*Step, error)
- func Latest(ctx context.Context, s store.Store, ctl identity.Card, id *identity.Identity, ...) (*Step, error)
- func ReadStep(ctx context.Context, s store.Store, ctl identity.Card, id *identity.Identity, ...) (*Step, error)
- type Submit
- type SubmitFile
- type Submitted
- type Ticket
- type Timer
Constants ¶
const ( KindSubmit = "submit" // record a tree at a prefix KindStart = "start" // start a run KindCancel = "cancel" // cancel a run; to a runner, cancel a job KindEvent = "event" // send a run an event KindAnswer = "answer" // answer a ticket KindResult = "result" // a job's outcome: a script's from its runner, a child's from the controller KindEmit = "emit" // a value a job sent up that the machine wants KindJob = "job" // a job for a runner KindSend = "send" // an event sent to an address, with what starts a run for it if there is one KindNote = "note" // something to be written in a run's record KindSet = "set" // set, remove or list a client's secrets or values )
The kinds of message.
const ( OfSecret = "secret" OfValue = "value" OpSet = "set" OpRemove = "remove" OpList = "list" )
What a Setting is of, and its operation.
const ( Waiting = "waiting" Running = "running" Done = "done" Failed = "failed" Cancelled = "cancelled" )
The words for where a run stands. A run that has been sent and not yet taken up is waiting; it has no head.
const ( AskScript = "script" // send a script to a runner AskChild = "child" // start a child machine AskCall = "call" // start a run at a location for a call job, or give a keyed run or a singleton its call AskAnswer = "answer" // give a call job the answer of the run it called, or why there is none AskCancel = "cancel" // cancel a job AskEvent = "event" // send an event to the parent or a child AskWake = "wake" // be woken at a time AskReceipt = "receipt" // answer a client's message AskResult = "result" // write what became of a run a client called, beside the call's receipt AskEnd = "end" // tell the parent the run has ended AskFail = "fail" // a job failed before anything was sent AskHold = "hold" // a job is held for the hooks before it AskNote = "note" // something to be seen in the record AskTell = "tell" // a note for the record of the run that started this one AskCommand = "command" // carry out a command for a job )
The kinds of thing a step asks for.
const ( EmitLog = "log" EmitProgress = "progress" )
The names of the emits Corbie itself gives a script.
const MaxCallers = 256
MaxCallers is how many calls a run keeps unanswered. Past it, the oldest call's job fails.
const MaxHeard = 64
MaxHeard is how many senders a run remembers the last message of.
const MessageLife = 5 * time.Minute
MessageLife is how long a message is good for when its sender says nothing.
const NotDelivered = " was not delivered: "
NotDelivered joins what a note names and why it was not delivered, in the controller's note to a sender that its send or its call was not delivered.
const ReceiptLife = 24 * time.Hour
ReceiptLife is how long a receipt is kept, and a call's receipt and result after the result is written.
const WakeTimer = "timer."
WakeTimer begins the name of a timer's wake: timer.<timer>~<step>, where step is the step that set it.
Variables ¶
var ErrNoRun = errors.New("there is no such run")
ErrNoRun is a run that does not exist: it was never started, or it is past keeping and gone.
var ErrOthers = fmt.Errorf("%w of this client's", ErrNoRun)
ErrOthers is a run in a tree of another client, whose file's read: does not list the client that asks: to that client it is no run.
Functions ¶
func MovedNote ¶ added in v0.51.0
MovedNote is the name of the controller's note to a sender that the event its message carried went to the run with the ID, not the run it named.
func Reads ¶
Reads says whether a client reads what is inside a run: the run is in one of the client's trees, or its head lists the client among those its file's read: names. listed says whether the head's list counts: it does for a client, which opens only what was sealed to it, and not for a job that runs a command, which the controller reads for with its own key.
func TreeVersion ¶
TreeVersion is the version of a tree: the SHA-256 of its files' paths and of the hashes of their contents.
func UndeliveredNote ¶ added in v0.51.0
UndeliveredNote is the name of the controller's note to a sender that the event or the call its message carried was not delivered.
Types ¶
type Above ¶
type Above struct {
Parent string `json:"parent,omitzero"` // the run that started it
Job string `json:"job,omitzero"` // the job of the parent's that it is
Depth int `json:"depth,omitzero"` // how many machines are above it
// MaxDepth is how many levels the root allows below itself.
MaxDepth int `json:"max_depth,omitzero"`
// Layers are the permissions that narrow it: the start's own list, and
// the job of each parent that led to it.
Layers []permission.Layer `json:"layers,omitzero"`
// Approve are the lists, from the machines above, of permissions that
// mark a job for approval.
Approve []string `json:"approve,omitzero"`
// Hooks are the hooks of each machine above that has some, the nearest
// first.
Hooks []HooksAbove `json:"hooks,omitzero"`
// IsHook says the run is itself run as a hook.
IsHook bool `json:"is_hook,omitzero"`
// Made says a machine above it, or the run itself, was made while
// running: its job gave a stored definition. The controller sets it when
// it starts a child, and a definition has no say in it.
Made bool `json:"made,omitzero"`
// Context is the directory last submitted at the run's tree.
Context string `json:"context,omitzero"`
// Values are the values set at the root's location or above, as they
// were at the root's first step, by name. A run a send or a call
// started takes those of its own location, never its sender's.
Values map[string]string `json:"values,omitzero"`
// Keep is the longest the run may be kept after it ends: no
// longer than what started it, so a child's record goes no later than
// its parent's.
Keep machine.Duration `json:"keep,omitzero"`
// Readers are the clients, beside the tree's, that its record is sealed
// to: those its root's file lists in read:, by name.
Readers []string `json:"readers,omitzero"`
// Cause is what started the run: the cause of its start.
Cause Cause `json:"cause,omitzero"`
// CallJob is, for a run a call job started, that job of the calling
// run's, which Cause names: the run's end is the job's result.
CallJob string `json:"call_job,omitzero"`
// CallReceipt is, for a run a client called in a tree it does not own,
// the call's message: the run's result is written beside its receipt.
CallReceipt *CallReceipt `json:"call_receipt,omitzero"`
}
Above is what a run was started under: who started it and the limits that came with the start.
type Arrived ¶
type Arrived struct {
machine.Event
Source string `json:"source,omitzero"`
Cause Cause `json:"cause,omitzero"`
Own bool `json:"own,omitzero"`
}
Arrived is an event with the message or wake it came from, and its cause. Own says the controller acted on it itself and the machine was not given it.
type Ask ¶
type Ask struct {
Kind string `json:"kind"`
// Name is the job a script, a child, a cancel or a failure is about.
Name string `json:"name,omitzero"`
Job *machine.Job `json:"job,omitzero"`
// Attempt is which attempt at the job this is, and Number a script's
// number in the run, under which its emits are filed.
Attempt int `json:"attempt,omitzero"`
Number int `json:"number,omitzero"`
Runner string `json:"runner,omitzero"`
// Card is the card of the runner a job goes to: what that job adds to
// the record is checked against it.
Card identity.Card `json:"card,omitzero"`
Child string `json:"child,omitzero"`
// To is the run an event is sent to; none for an event a root
// sends up, which is only written here.
To string `json:"to,omitzero"`
Event *machine.Event `json:"event,omitzero"`
// Location is the location an event is sent to or a call starts a run
// at. Key is the key an event is sent to, and Run the run it is started
// as when no run has the key, or the run a call starts.
Location string `json:"location,omitzero"`
Key string `json:"key,omitzero"`
Run string `json:"run,omitzero"`
// Client is the client an event was addressed to, which has no inbox.
Client string `json:"client,omitzero"`
// Answer is the calling job of the run To that an answer goes to.
Answer string `json:"answer,omitzero"`
// Direct says the event was sent to one run by its ID, which is To.
Direct bool `json:"direct,omitzero"`
// Undelivered says the event was for a child that is not running, or
// for an address that names no running run able to take it.
Undelivered bool `json:"undelivered,omitzero"`
// At is a wake's time, or a job's due time.
At time.Time `json:"at,omitzero"`
What string `json:"what,omitzero"` // what a wake is for
// Message is the name of the message, in an inbox, that carrying this
// out writes.
Message string `json:"message,omitzero"`
Sender string `json:"sender,omitzero"` // whose message a receipt or a call's result answers
Receipt *Receipt `json:"receipt,omitzero"`
Result *CallResult `json:"result,omitzero"`
Error *machine.Error `json:"error,omitzero"`
Output any `json:"output,omitzero"`
Text string `json:"text,omitzero"`
}
An Ask is one thing a step asked for. Each kind holds these fields:
script Name Job Attempt Number Runner Card At What Message child Name Job Attempt Child Message call Name Job Event Message Location Key Run To Client Direct Undelivered Text event as a call, with Attempt for an event sent up to the parent answer To Answer Message, and Output or Error; from a send job, an event's too cancel Name Message, and Runner At, or Child, or Run wake At What receipt Sender Message Receipt Run result Sender Message Result end To Name Output Error Message fail Name Message Error hold Name Job note Text tell To Message Text command Name Job At Message
func (*Ask) Address ¶
Address is where a send or a call was sent: its location, with the run it was sent to by its ID or the key, or the client.
type CallReceipt ¶
A CallReceipt names a client's call: the client and its message.
type CallResult ¶
type CallResult struct {
Status string `json:"status"`
Output any `json:"output,omitzero"`
Error *machine.Error `json:"error,omitzero"`
}
A CallResult is what became of a run a client called in a tree it does not own, written beside the call's receipt when the run ends: its status, and its output or error. The blobs its output names are beside it.
type Cause ¶
type Cause struct {
Run string `json:"run,omitzero"`
Step int `json:"step,omitzero"`
Client string `json:"client,omitzero"`
Message string `json:"message,omitzero"`
Principal string `json:"principal,omitzero"`
}
A Cause is what sent an event: the step of a run that asked for it, or a message of a client, with the principal the client sent it for where the message names one. A note or a failure the controller writes for a step names that step. An event from the run's own script job or timer has none. A Cause is apart from a message's From, the run the machine answers, and an event's Source, the file the message came in.
type Emit ¶
type Emit struct {
Job string `json:"job"` // the job that emitted
Number int `json:"number"` // which of the job's emit entries it is, counted from one
Values []Emitted `json:"values"`
}
An Emit is one emit entry of a record: values a job emitted, in the order it made them, written by the job's runner.
type EmitNote ¶
type EmitNote struct {
Job string `json:"job"`
Name string `json:"name"`
Index int `json:"index"`
Data any `json:"data,omitzero"`
}
An EmitNote tells the controller of a value a job sent up that the machine wants to act on. Index is which value of that name it is from that job, counting from one.
type Emitted ¶
type Emitted struct {
Name string `json:"name"`
Data any `json:"data,omitzero"`
At time.Time `json:"at"`
}
Emitted is one value a job emitted while it ran: a log line, a note of progress, a named value.
type Going ¶
type Going struct {
machine.Job
Asked int `json:"asked"` // which time its name asked for a job
Attempt int `json:"attempt"` // which attempt this is
// Runner is the runner a job was sent to.
Runner string `json:"runner,omitzero"`
// Child is the run a machine was started as.
Child string `json:"child,omitzero"`
// Called is the run a call job started.
Called string `json:"called,omitzero"`
// Answer says a call job waits for the answer of a keyed run or a
// singleton, from whichever run took the call.
Answer bool `json:"answer,omitzero"`
// Needs is the permission a command needs, worked out when the job is
// asked for.
Needs string `json:"needs,omitzero"`
// Due is when a job's result is due.
Due time.Time `json:"due,omitzero"`
// Began is when this attempt was sent on its way.
Began time.Time `json:"began,omitzero"`
// Again is when the job restarts.
Again time.Time `json:"again,omitzero"`
// Anew says the job ended well and restarts as a new job.
Anew bool `json:"anew,omitzero"`
// Restarts is how many times the job has restarted, and Restarted when,
// for a limit in a length of time.
Restarts int `json:"restarts,omitzero"`
Restarted []time.Time `json:"restarted,omitzero"`
// Doubled is how many times its delay has doubled.
Doubled int `json:"doubled,omitzero"`
// Wake is what the job's wake, for its due time or its next attempt,
// is called.
Wake string `json:"wake,omitzero"`
// Held says the job waits for the hooks before it, and has not started.
Held bool `json:"held,omitzero"`
// Hooks are the hooks still to run for the job: before it starts,
// while it is held, and after it, once it has ended.
Hooks []HookRef `json:"hooks,omitzero"`
// For is the job a hook's job runs for.
For string `json:"for,omitzero"`
// Outcome is how the job ended, kept while the hooks after it run.
Outcome *machine.Event `json:"outcome,omitzero"`
// Changed says a hook gave the job another input, and Given is the input
// it was first given, which the job has again when it restarts as a new
// job.
Changed bool `json:"changed,omitzero"`
Given any `json:"given,omitzero"`
}
A Going is a job still going.
type Head ¶
type Head struct {
Name string `json:"name"` // the run
Machine string `json:"machine"` // what the definition is called
Type string `json:"type"`
Status string `json:"status"`
// Failure says how a failed run failed: error, timeout or denied.
Failure string `json:"failure,omitzero"`
Step int `json:"step"`
// Stepped is when its latest step was written.
Stepped time.Time `json:"stepped"`
Started time.Time `json:"started"`
Ended time.Time `json:"ended,omitzero"`
Parent string `json:"parent,omitzero"`
// Location is where the run's machine lives, Key is its key at a keyed
// location, and Cause is what started it.
Location string `json:"location,omitzero"`
Key string `json:"key,omitzero"`
Cause Cause `json:"cause,omitzero"`
Jobs int `json:"jobs,omitzero"`
Timers int `json:"timers,omitzero"`
Tickets []string `json:"tickets,omitzero"`
Labels map[string]string `json:"labels,omitzero"`
// Readers are the clients, beside its tree's, its record is sealed to.
Readers []string `json:"readers,omitzero"`
// Keep is how long the run is kept after it ends.
Keep machine.Duration `json:"keep,omitzero"`
}
A Head is the small public summary of a run, signed by the controller and sealed to nobody. Apart from its location, key, labels and readers it holds nothing the run was given or produced.
func ReadHead ¶
func ReadHead(ctx context.Context, s store.Store, ctl identity.Card, name string) (*Head, store.Mark, error)
ReadHead reads a run's head, wherever it is. A run whose head is among the finished has ended, also when a head is still among the running. A head that moves between the two looks is found.
type HookRef ¶
type HookRef struct {
Level int `json:"level"`
Name string `json:"name"`
After bool `json:"after,omitzero"`
}
A HookRef names one hook that is to run for a job: the machine that declares it, -1 for the job's own and otherwise its place in the hooks from above, and the hook's name there.
type HooksAbove ¶
type HooksAbove struct {
Hooks map[string]*machine.HookSpec `json:"hooks"`
Definition blob.Ref `json:"definition"`
Input any `json:"input,omitzero"`
Layers []permission.Layer `json:"layers,omitzero"`
// Run, Key and Principal are what an expression reads of the run
// that declares the hooks.
Run string `json:"run"`
Key *string `json:"key,omitzero"`
Principal string `json:"principal,omitzero"`
}
HooksAbove are the hooks a machine takes from one machine above: the hooks as written, the definition that declares them, and the input and the run their values are filled from.
type Job ¶
type Job struct {
Run string `json:"run"`
// Machine is the name the definition of the job's run gives.
Machine string `json:"machine"`
Name string `json:"name"` // the job's full name, its attempt included
Attempt int `json:"attempt"`
// Number is the job's number in the run: the runner files its
// emits under it.
Number int `json:"number"`
// Request names what asked: every attempt at the same job has the same.
Request string `json:"request"`
// Location is the location of the job's run, as the controller gives
// it: the runner takes only the jobs of runs at or under its prefixes.
Location string `json:"location,omitzero"`
Script blob.Ref `json:"script"`
// Path is the script's path as the definition names it, and none for
// a stored script. Files are keyed the same way.
Path string `json:"path,omitzero"`
Files map[string]blob.Ref `json:"files,omitzero"`
Input any `json:"input,omitzero"`
// Layers are every layer of permissions that applies, each by name.
Layers []permission.Layer `json:"layers"`
// Secrets are the values of the secrets the job names.
Secrets map[string]string `json:"secrets,omitzero"`
Timeout machine.Duration `json:"timeout"`
Memory int64 `json:"memory,omitzero"`
// Due is when the job's result is due.
Due time.Time `json:"due"`
// Wants names the emitted values the machine wants to hear about.
Wants []string `json:"wants,omitzero"`
// Readers are the cards of the clients what the job adds to the record
// is sealed to, beside the controller: the client that owns the root's
// tree, and those its root's file lists in read:.
Readers []identity.Card `json:"readers"`
}
A Job is everything a runner needs to run a script: with the job and the store, and nothing else from the controller, the runner can run it.
type Listed ¶
type Listed struct {
Name string `json:"name"`
At string `json:"at"`
Value string `json:"value,omitzero"`
}
Listed is one secret or value a list gives: its name, the location it is set at, and a plain value's value.
type Message ¶
type Message struct {
Kind string `json:"kind"`
// Run is the run the message is for.
Run string `json:"run,omitzero"`
// From is, in a message the controller sends itself, the run it
// is sent on behalf of.
From string `json:"from,omitzero"`
// To is the address an event is sent to or a call starts a run at, and
// Sender the run or client it is from. Only the controller writes
// Sender.
To *machine.Address `json:"to,omitzero"`
Sender *machine.Address `json:"sender,omitzero"`
// Cause is, in a message the controller sends itself, what caused it:
// the step that asked for it, or the client's message it carries on.
Cause *Cause `json:"cause,omitzero"`
// Principal is, in a client's message, the principal the client sends it
// for. It is the client's claim.
Principal string `json:"principal,omitzero"`
Start *Start `json:"start,omitzero"`
Submit *Submit `json:"submit,omitzero"`
Event *machine.Event `json:"event,omitzero"`
Answer *Answer `json:"answer,omitzero"`
Result *Result `json:"result,omitzero"`
Emit *EmitNote `json:"emit,omitzero"`
Job *Job `json:"job,omitzero"`
Note string `json:"note,omitzero"`
Set *Setting `json:"set,omitzero"`
// Cancel names, for a runner, the job that is cancelled.
Cancel string `json:"cancel,omitzero"`
}
A Message is what one party leaves in another's inbox. Kind says which of the parts it carries.
type Receipt ¶
type Receipt struct {
Taken bool `json:"taken"`
Refused string `json:"refused,omitzero"`
// Denied is a start a permission refused, as a run's failure gives it:
// what was refused, the layer that refused it and the fix.
Denied *machine.Error `json:"denied,omitzero"`
// Problems are what is wrong with a definition that was refused.
Problems machine.Problems `json:"problems,omitzero"`
// Tree is what a submit that was taken did.
Tree *Submitted `json:"tree,omitzero"`
// Acted says, for an event, whether the machine acted on it or had no
// rule for it.
Acted *bool `json:"acted,omitzero"`
// Run is, for an event sent to an address, the run that took it.
Run string `json:"run,omitzero"`
// Listed is, for a list of secrets or values, each name set at a
// location the client may set at; a secret's with no value.
Listed []Listed `json:"listed,omitzero"`
// Answers is, for a set, remove or list of secrets or values, the hash
// of the setting the receipt answered.
Answers string `json:"answers,omitzero"`
}
A Receipt is the controller's answer to one message of a client's: that it was taken, or why it was refused.
type Recorded ¶
type Recorded struct {
Location string `json:"location"`
Lifetime string `json:"lifetime,omitzero"`
What string `json:"what"`
Run string `json:"run,omitzero"`
}
Recorded is what a submit did at one location: started, restarted, changed, recorded, removed or problem. Run is the run it started.
type Result ¶
type Result struct {
Job string `json:"job"` // the job, as its run's step named it
Attempt int `json:"attempt,omitzero"`
// Status is done, or one of the ways a job fails.
Status string `json:"status"`
Output any `json:"output,omitzero"`
Error *machine.Error `json:"error,omitzero"`
// Used lists the permissions a job used.
Used []string `json:"used,omitzero"`
// Final says a failure is not to be tried again.
Final bool `json:"final,omitzero"`
}
A Result is how a job ended.
type SendNote ¶ added in v0.51.0
type SendNote struct {
// Message is the message that sent the event.
Message string
// Why is why it was not delivered, or "".
Why string
// contains filtered or unexported fields
}
A SendNote is the controller's note in a sender's record of an event the sender sent to an address: why it was not delivered, or the run it went to in place of the run the step named.
type Setting ¶
type Setting struct {
Of string `json:"of"`
Op string `json:"op"`
At string `json:"at,omitzero"`
Name string `json:"name,omitzero"`
Value string `json:"value,omitzero"`
}
A Setting is a client's set, remove or list of the secrets or the plain values at the locations it may set them at. Of is secret or value, and Op set, remove or list. Value is what set sets.
type SourceFile ¶
A SourceFile is one file of a tree: its contents, and their SHA-256.
type Start ¶
type Start struct {
Definition blob.Ref `json:"definition,omitzero"`
Input any `json:"input,omitzero"`
InputBlob blob.Ref `json:"input_blob,omitzero"`
Labels map[string]string `json:"labels,omitzero"`
// Allow is the start's own list, which narrows the root and everything
// below it.
Allow *permission.Layer `json:"allow,omitzero"`
// Timeout is how long the run may take, if the start says.
Timeout machine.Duration `json:"timeout,omitzero"`
// Seed is the secret the run's tickets and random numbers follow
// from.
Seed []byte `json:"seed"`
// Above is set by the controller when it starts a child.
Above *Above `json:"above,omitzero"`
// Location is the location the run is started at: its machine is the
// file recorded there.
Location string `json:"location,omitzero"`
// Key is, for an event sent to a key, the key of the run it starts.
Key string `json:"key,omitzero"`
// Tree is the prefix of the tree the location is in, for a child, which
// runs at its parent's location.
Tree string `json:"tree,omitzero"`
// Replaces is, for a singleton a submit starts again, the runs it
// replaces: the new run starts once every one has ended.
Replaces []string `json:"replaces,omitzero"`
// Run is the run an event sent to a key starts, where it names one: the
// event's data is its input. What a client or a job starts is the
// message's own run.
Run string `json:"run,omitzero"`
}
A Start starts a run. A client's start names a location, and its input is the blob InputBlob in the run's record; Definition and Input are written by the controller, from the file recorded there and that blob, or from the job that starts a child.
type State ¶
type State struct {
Machine string `json:"machine"`
Type string `json:"type"`
Status string `json:"status"`
Output any `json:"output,omitzero"`
Error *machine.Error `json:"error,omitzero"`
Started time.Time `json:"started"`
Ended time.Time `json:"ended,omitzero"`
Definition blob.Ref `json:"definition"`
Input any `json:"input,omitzero"`
Labels map[string]string `json:"labels,omitzero"`
// Location is where the run's machine lives: the location of the
// file it was started from, or of the run that started it as a child.
// Tree is the prefix of the tree that location is in.
Location string `json:"location,omitzero"`
Tree string `json:"tree,omitzero"`
// Key is the run's key at a keyed location, while it runs.
Key string `json:"key,omitzero"`
// Counted says a transient run took a key file under its own ID, which
// its location's limits: { runs } counts, while it runs.
Counted bool `json:"counted,omitzero"`
// Lifetime is the lifetime of the file a root was started from at its
// location. A child has none.
Lifetime string `json:"lifetime,omitzero"`
// Title is what the definition's title filled in to when the run
// started.
Title string `json:"title,omitzero"`
// Seed is the run's own secret: its keys and random numbers follow
// from it.
Seed []byte `json:"seed"`
// Keep is how long the run is kept after it ends.
Keep machine.Duration `json:"keep,omitzero"`
// Hooks are the hooks its definition names, for what it starts.
Hooks map[string]*machine.HookSpec `json:"hooks,omitzero"`
// Recorded is what the run read at its first step of the machine
// recorded at each location its definition calls in full, by location.
Recorded map[string]machine.Recorded `json:"recorded,omitzero"`
// Above is what the run was started under.
Above Above `json:"above"`
// TimeoutAt is when the run passes its timeout, if it has one.
TimeoutAt time.Time `json:"timeout_at,omitzero"`
// Inner is the machine type's own state.
Inner jsontext.Value `json:"inner,omitzero"`
// Jobs are the jobs still going, by the name that asked for them.
Jobs map[string]*Going `json:"jobs,omitzero"`
// Timers are the timers set, by name.
Timers map[string]Timer `json:"timers,omitzero"`
// Tickets are the tickets waited on, by the id the machine gave each.
Tickets map[string]Ticket `json:"tickets,omitzero"`
// Asked counts how many times each name has asked for a job.
Asked map[string]int `json:"asked,omitzero"`
// JobsStarted counts the jobs the run has started.
JobsStarted int `json:"jobs_started,omitzero"`
// Scripts counts the attempts at scripts the run has sent to
// runners, and numbers each: what an attempt adds to the record is
// filed under its number, never its name.
Scripts int `json:"scripts,omitzero"`
// Heard is the name of the last message taken from each of the most
// recent MaxHeard senders, oldest first: the run's parent and each
// run that sent to it by address. The controller writes those under
// names that sort in the order sent, and may write one again when it
// repeats a carry-out: one that does not sort after the last taken from
// its sender has been taken already.
Heard []Heard `json:"heard,omitzero"`
// Emitted counts, for each job and name, the values of its attempt
// given to the machine, so one that arrives twice is given once.
Emitted map[string]int `json:"emitted,omitzero"`
// Sent counts the events the run has sent up to its parent.
Sent int `json:"sent,omitzero"`
// Used lists the permissions used by every job in the run and
// below it.
Used []string `json:"used,omitzero"`
// Answered remembers, by a short mark, the last few tickets answered, so a
// second answer can be told it came second.
Answered []string `json:"answered,omitzero"`
// Noted remembers, by a short mark, the last few notes the controller
// wrote the run, so one written again is recorded once.
Noted []string `json:"noted,omitzero"`
// Callers are the calls the run has taken and not answered, oldest
// first: each caller's address, with its calling job.
Callers []machine.Address `json:"callers,omitzero"`
}
State is everything about a run that is not its history.
type Step ¶
type Step struct {
Number int `json:"number"`
Time time.Time `json:"time"`
// Events are what arrived, in the order they were taken.
Events []Arrived `json:"events,omitzero"`
// Used names every message and wake the step used. They are deleted
// only when the step has been carried out.
Used []string `json:"used,omitzero"`
State State `json:"state"`
// Asks are what the step asked for, each under a name the entry fixes.
Asks []Ask `json:"asks,omitzero"`
}
A Step is one step entry of a record: the events that arrived and what they came from, the state the run was left in, and what the step asked for. The latest step is the run's whole state.
func Current ¶
func Current(ctx context.Context, s store.Store, ctl identity.Card, id *identity.Identity, name string) (*Step, error)
Current gives a run's latest step, found from its head. Older steps may have been trimmed, so reading always starts from the number the head gives. It gives nil where the run has no head.
type Submit ¶
type Submit struct {
Prefix string `json:"prefix"`
Directory string `json:"directory,omitzero"`
Files map[string]SubmitFile `json:"files,omitzero"`
Problems []string `json:"problems,omitzero"`
Remove bool `json:"remove,omitzero"`
// Source is every file of the directory, by its path from it, among the
// message's uploads.
Source map[string]SourceFile `json:"source,omitzero"`
// From is the version the tree must be at for the submit to be taken:
// any, where it is empty.
From string `json:"from,omitzero"`
// Export marks a message that submits nothing and asks for the tree's
// files.
Export bool `json:"export,omitzero"`
// Force marks a submit from a directory that replaces a tree last
// changed from no directory, whatever the directory lacks of it.
Force bool `json:"force,omitzero"`
// File is, for a tree of one file, that file's path among the tree's
// files: its machine is at the prefix.
File string `json:"file,omitzero"`
// Job is, for a submit or an export a run's step asked for, the job that
// asked: the controller writes its result where it writes a client its
// receipt. Only the controller writes it.
Job string `json:"job,omitzero"`
}
A Submit records a directory as a tree at a prefix. Files are its machines, by location, each uploaded with the message; Problems are the locations of files that could not be read, which keep what was recorded before. One with Remove removes the tree at the prefix, and the secrets and values set at or under it: it names no file.
func WriteTree ¶
func WriteTree(ctx context.Context, prefix string, machines []*machine.TreeFile, files map[string][]byte, kept map[string]blob.Ref, atOnce int, write func(typ string, contents []byte) (blob.Ref, error)) (*Submit, error)
WriteTree writes a tree out as the submit that records it at a prefix: each machine as a stored definition, and every file of the tree. write stores a blob, and at most atOnce are written side by side. A file among kept has its blob already, and is not written. A machine with a problem is named among the submit's problems, so that its location keeps what was recorded before; one whose path gives no location is left out.
type SubmitFile ¶
type SubmitFile struct {
Definition blob.Ref `json:"definition"`
Hash string `json:"hash"`
Secrets []string `json:"secrets,omitzero"`
Values []string `json:"values,omitzero"`
}
A SubmitFile is one machine of a submit: its stored definition among the message's uploads, the hash of what it runs, and the names of the secrets and the values it uses.
type Submitted ¶
type Submitted struct {
Locations []Recorded `json:"locations,omitzero"`
Cancelled []string `json:"cancelled,omitzero"`
Before string `json:"before,omitzero"`
Missing []string `json:"missing,omitzero"`
Untrusted []string `json:"untrusted,omitzero"`
Removed []string `json:"removed,omitzero"`
// Version is the tree's version once the submit is done, or as an export
// found it, and Files what an export gives: each file of the tree by its
// path, beside the receipt.
Version string `json:"version,omitzero"`
Files map[string]blob.Ref `json:"files,omitzero"`
// File is, for an export of a tree of one file, that file's path.
File string `json:"file,omitzero"`
}
Submitted is what a submit did: what became of each location of the tree, the runs it cancelled, the directory last submitted there when it was another, the secrets and values the files use that are not set, and the clients the files' read: lists that the controller does not trust. Removed are the secrets and values a removal of the tree removed, each as "secret NAME at /location" or "value NAME at /location".