Documentation
¶
Overview ¶
Package client starts runs and reads what happened to them. The command line, the gateway and an application written in Go all use it, so there is one behaviour and one set of words for all of them.
Index ¶
- Constants
- Variables
- func ContextOf(dir, file string) (context, rel string, err error)
- func IsTest(file string) bool
- func ReadMachine(dir, rel string) (*machine.Draft, error)
- func Script(file string, load func(path string) ([]byte, error), job ScriptJob) (*machine.Draft, error)
- func SentTo(ask *instance.Ask) string
- func StartMessage(run string) string
- func Taking(life time.Duration) time.Duration
- func WithFiles(input any, files map[string]InputFile) (any, error)
- func Within(dir, name string) (string, bool, error)
- type Call
- type Case
- type Client
- func (c *Client) Address(ctx context.Context, text string) (machine.Address, error)
- func (c *Client) As(principal string) *Client
- func (c *Client) Cancel(ctx context.Context, run string, life time.Duration) (string, error)
- func (c *Client) Definition(ctx context.Context, id string) (*machine.Definition, error)
- func (c *Client) Fetch(ctx context.Context, id, path string) (io.Reader, File, error)
- func (c *Client) Files(ctx context.Context, id string) (map[string]File, error)
- func (c *Client) Follow(ctx context.Context, id string, interval time.Duration, tell func(Entry)) (*Run, error)
- func (c *Client) List(ctx context.Context, filter Filter) ([]*Run, error)
- func (c *Client) ListSecrets(ctx context.Context, life time.Duration) (string, error)
- func (c *Client) ListValues(ctx context.Context, life time.Duration) (string, error)
- func (c *Client) NewRun() (string, error)
- func (c *Client) OutputWithBytes(ctx context.Context, id string, most int64) (any, error)
- func (c *Client) Receipt(ctx context.Context, message string) (*instance.Receipt, error)
- func (c *Client) Record(ctx context.Context, id string, tell func(Entry)) (*Run, error)
- func (c *Client) RemoveSecret(ctx context.Context, at, name string, life time.Duration) (string, error)
- func (c *Client) RemoveTree(ctx context.Context, prefix string, life time.Duration) (string, error)
- func (c *Client) RemoveValue(ctx context.Context, at, name string, life time.Duration) (string, error)
- func (c *Client) Reply(ctx context.Context, run, ticket string, value any, life time.Duration) (string, error)
- func (c *Client) Send(ctx context.Context, to machine.Address, event string, data any, ...) (string, error)
- func (c *Client) SetSecret(ctx context.Context, at, name, value string, life time.Duration) (string, error)
- func (c *Client) SetValue(ctx context.Context, at, name, value string, life time.Duration) (string, error)
- func (c *Client) Show(ctx context.Context, id string) (*Run, error)
- func (c *Client) Start(ctx context.Context, start Start) (string, error)
- func (c *Client) Started(ctx context.Context, id string, interval time.Duration) error
- func (c *Client) Step(ctx context.Context, id string, number int) (*Entry, error)
- func (c *Client) Submit(ctx context.Context, tree *Tree, life time.Duration) (string, error)
- func (c *Client) Taken(ctx context.Context, id string, life, interval time.Duration) error
- func (c *Client) Tickets(ctx context.Context, id string) (map[string]string, error)
- func (c *Client) Undelivered(ctx context.Context) ([]Undelivered, error)
- func (c *Client) Wait(ctx context.Context, id string, interval time.Duration) (*Run, error)
- func (c *Client) WaitReceipt(ctx context.Context, message string, life, interval time.Duration) (*instance.Receipt, error)
- func (c *Client) Watch(ctx context.Context, filter Filter, interval time.Duration, tell func(Update)) error
- func (c *Client) Who(ctx context.Context) (Who, error)
- type Emitted
- type Entry
- type Expect
- type File
- type Filter
- type InputFile
- type Label
- type Local
- func (l *Local) Close()
- func (l *Local) Idle(ctx context.Context) (bool, error)
- func (l *Local) MoveClock(by time.Duration)
- func (l *Local) Now() time.Time
- func (l *Local) Run(ctx context.Context, draft *machine.Draft, start Start) (string, error)
- func (l *Local) RunTree(ctx context.Context, tree *Tree, at string, start Start) (string, error)
- func (l *Local) SetClock(at time.Time)
- func (l *Local) SetSecret(ctx context.Context, at, name, value string) error
- func (l *Local) SetValue(ctx context.Context, at, name, value string) error
- func (l *Local) Still(ctx context.Context) (bool, error)
- func (l *Local) Timed(ctx context.Context) (bool, error)
- func (l *Local) WhileMoving(ctx context.Context) (context.Context, context.CancelFunc)
- type Look
- type Machine
- type Reply
- type Result
- type Run
- type ScriptJob
- type StandIn
- type Start
- type Step
- type TestFile
- type Texts
- type Tree
- type Undelivered
- type Update
- type Who
Constants ¶
const ( CaseOK = "ok" CaseFails = "fails" CaseFinding = "finding" )
The outcomes of a case.
const ConfigName = ".corbie"
ConfigName is the name of the config directory corbie up makes in the directory it submits. Nothing in it is a machine.
const ScriptStage = "script"
ScriptStage is the name of the one stage a script is wrapped in.
Variables ¶
var ErrCalled = errors.New("the run is a call into a tree of another client, and only the call's result is shown")
ErrCalled is a run this client started as a call into a tree of another client: only the call's result is shown.
var ErrFilesTooLarge = errors.New("the blobs of the output are more than are given with a run")
ErrFilesTooLarge is an output whose blobs are more than are given with a run.
var ErrNeverTaken = fmt.Errorf("%w: its start was never taken up", ErrNoRun)
ErrNeverTaken is a run whose start stopped being good before a controller took it up.
var ErrNoFile = errors.New("the run shows no file at the path")
ErrNoFile is a path that names no blob of the run.
var ErrNoRecord = errors.New("the run has no record to read")
ErrNoRecord is a run with nothing in its record to read yet: it is waiting to start, or its start was refused.
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 ErrNoStep = errors.New("the run has no step")
ErrNoStep is a step's number that a run's record does not hold.
var ErrNotTaken = errors.New("the message was not taken up: it is no longer good and no answer has come (is a controller running?)")
ErrNotTaken is a message that stopped being good before a controller answered it.
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 this client: to this client it is no run.
var ErrStart = errors.New("the start cannot be sent")
ErrStart is a start that cannot be sent as it was given.
var ErrStill = errors.New("each run still running waits on an event that nothing in this process sends")
ErrStill is the cause of a context WhileMoving gave, once nothing can move any run.
var LocalInterval = time.Second
LocalInterval is how long a role in one process sleeps when nothing is due and nothing wakes it.
var Statuses = []string{instance.Running, instance.Done, instance.Failed, instance.Cancelled}
Statuses are the words a listing can be narrowed to by status: what a run that is listed can be.
Functions ¶
func ContextOf ¶ added in v0.47.0
ContextOf gives the context of a file run from dir, and the file's path from there: dir, or the file's own directory for a file outside it.
func IsTest ¶ added in v0.46.0
IsTest says whether a file is a test file, by its name: one that ends in .test.yaml. A test file is no machine, and has no location.
func ReadMachine ¶ added in v0.12.0
ReadMachine reads the machine at rel in the context dir. A path in it may name any file inside dir and none outside.
func Script ¶ added in v0.7.0
func Script(file string, load func(path string) ([]byte, error), job ScriptJob) (*machine.Draft, error)
Script wraps the script file at file, a path from the context, in a flow of one stage, whose job runs it with the run's input and whose output is the flow's. The flow is named after the file, and read as a definition beside it. load gives a file by its path from the context: the script and each of job.Files. Nothing is sent.
func SentTo ¶ added in v0.46.0
SentTo is where a step sent an event, as the record's lines write it.
func StartMessage ¶ added in v0.46.0
StartMessage is the name of the message that starts a run: it follows from the run's name, so the answer to a start can be found by one who knows only the run.
func Taking ¶ added in v0.28.0
Taking is how long after it is sent a controller may still take a message: its life and the allowance for clocks, by a controller's clock that may be the allowance behind this client's.
func WithFiles ¶ added in v0.7.0
WithFiles gives an input with each file at its place, such as report or files[0].file. A map or a list the place goes through is made where the input has none, and an item of a list goes at its end or at an item that is null. The input is a map of names, or nothing, and a place that holds a value other than null is refused.
Types ¶
type Call ¶ added in v0.47.0
type Call struct {
ID string `yaml:"id" json:"id,omitzero"`
Name string `yaml:"name" json:"name,omitzero"`
Args any `yaml:"args" json:"args,omitzero"`
}
A Call is one call of a tool in a reply, as a model writes it.
type Case ¶ added in v0.46.0
type Case struct {
Name string `yaml:"-"`
Input any `yaml:"input"`
Files map[string]string `yaml:"files"` // a file given as input at each place, by its path
Values map[string]string `yaml:"values"` // a value by its name, or by its location and name
Secrets map[string]string `yaml:"secrets"` // the environment variable each secret's value is read from
Clock string `yaml:"clock"` // the time every role's clock is at when the run starts
Jobs map[string]*StandIn `yaml:"jobs"` // a stand-in for each job named
Steps []*Step `yaml:"steps"`
Expect Expect `yaml:"expect"`
// Finding marks a case in which Corbie does not do what its specs say.
Finding string `yaml:"finding"`
}
A Case is one run of the machine tested: what it is given, what a client does while it runs, and how it should end.
type Client ¶
type Client struct {
ID *identity.Identity
Controller identity.Card
Store store.Store
// Now is the client's clock.
Now func() time.Time
// Principal is the principal the client sends its messages for, if it says:
// the controller writes it into the cause of what each message does.
Principal string
// contains filtered or unexported fields
}
A Client is one party's way into a controller's store. With no identity it is a viewer: it can list the heads the store lets it read and nothing more.
func Remote ¶ added in v0.30.0
Remote makes a client that sends everything to a gateway, as the client the token names. It holds no key and reads no store: each thing the package does is one request to the gateway, which does it.
func (*Client) Address ¶ added in v0.17.0
Address reads the address of a run as a client writes it: a location from /, a location and a key as /location#key, or a run's ID, which is at the location its head names. A run of the client's own is named by its ID alone until it has a head.
func (*Client) Cancel ¶
Cancel asks for a run to be cancelled. It gives the name of the message, by which its receipt is found. Like a start, a cancel, an event and an answer are each good for the life given, or for a few minutes if it is zero.
func (*Client) Definition ¶
Definition gives the definition a run was started from, in its full form, as it is shown: each script and each machine it names as a blob's type, its size and the path to ask for it by.
func (*Client) Fetch ¶
Fetch gives the contents of a blob of a run, by the path it was shown with.
A path shown in a run's result says where the blob is in the output: report, pages[2]. A path shown anywhere else begins with the place of what holds the blob (steps/<number> or emits/<job>/<number>, which is an entry of the run's record, input or definition) and after the next slash says where the blob is in that.
func (*Client) Files ¶
Files lists the blobs in a run's result by their paths, each with the name it has in the value that holds it. It lists every blob a path of the result fetches: one written out inside a text is among them.
func (*Client) Follow ¶
func (c *Client) Follow(ctx context.Context, id string, interval time.Duration, tell func(Entry)) (*Run, error)
Follow gives each entry of a run's record as it is written, with those of every instance below it, and ends when the run and everything below it have ended, saying how the run ended. Each entry is read once. A look that cannot reach the store is made again at the next interval. A follow that is cut short gives what is new in the record, then the run as it stands.
func (*Client) List ¶
List gives the runs this party may read, each as its head gives it: every instance, not only roots. A client sees its own and those whose file's read: lists it; a viewer with access to heads sees everyone's.
func (*Client) ListSecrets ¶ added in v0.26.0
ListSecrets asks the controller for the names of the secrets set where this client may set them, and where each is set. The receipt lists them.
func (*Client) ListValues ¶ added in v0.26.0
ListValues asks the controller for the values set where this client may set them, and where each is set. The receipt lists them.
func (*Client) NewRun ¶
NewRun chooses the name of a run before it is started, so that an application can note it before anything is sent.
func (*Client) OutputWithBytes ¶ added in v0.36.0
OutputWithBytes gives a run's output as Show gives it, with the bytes of each blob beside its path, type and size, as base64 in data. The blobs are named where the shown output is made, so each is the one its path fetches.
The blobs are at most most bytes together, each counted where it is named: past that the error is ErrFilesTooLarge and no more is read. Through a gateway, the limit is that gateway's.
func (*Client) Receipt ¶
Receipt reads the controller's answer to a message this client sent. It gives nil while there is none.
func (*Client) Record ¶
Record gives each entry of a run's record so far, with those of every instance below it, and then the run as it stands: what a follow gives, without staying.
func (*Client) RemoveSecret ¶ added in v0.26.0
func (c *Client) RemoveSecret(ctx context.Context, at, name string, life time.Duration) (string, error)
RemoveSecret asks the controller to remove a secret set at a location.
func (*Client) RemoveTree ¶ added in v0.34.0
RemoveTree removes the tree at a prefix: the controller cancels every run at its locations, removes the locations and the secrets and values set at or under the prefix, and then the tree. It gives the name of the message, by which its receipt is found.
func (*Client) RemoveValue ¶ added in v0.26.0
func (c *Client) RemoveValue(ctx context.Context, at, name string, life time.Duration) (string, error)
RemoveValue asks the controller to remove a value set at a location.
func (*Client) Reply ¶
func (c *Client) Reply(ctx context.Context, run, ticket string, value any, life time.Duration) (string, error)
Reply answers a ticket of a run. The ticket is the authority: any client that holds it may answer.
func (*Client) Send ¶
func (c *Client) Send(ctx context.Context, to machine.Address, event string, data any, life time.Duration) (string, error)
Send sends a named event to a run by its address. The controller takes it as it takes a run's send, and its receipt names the run that took it.
func (*Client) SetSecret ¶ added in v0.26.0
func (c *Client) SetSecret(ctx context.Context, at, name, value string, life time.Duration) (string, error)
SetSecret sends the controller a secret to set at a location, at or under a prefix where this client could submit a tree. It gives the name of the message, by which its receipt is found; the receipt never holds the value.
func (*Client) SetValue ¶ added in v0.26.0
func (c *Client) SetValue(ctx context.Context, at, name, value string, life time.Duration) (string, error)
SetValue sends the controller a value to set at a location, as SetSecret does a secret.
func (*Client) Show ¶
Show gives one run: where it stands and, once it has ended, how. It is shown from its record: the head may be a moment behind, or not there yet.
func (*Client) Start ¶
Start starts a run of a location. The files of the input, and then the input itself, are written into the run's record first, and then the start is sent. It gives the run's name.
func (*Client) Started ¶ added in v0.17.0
Started stays until a run a submit started has been taken up. The controller's start of it is good for ever, as a singleton started again waits for the runs it replaces to end, and so the wait has no limit.
func (*Client) Step ¶
Step gives one step entry of a run's record, as it is shown, with the outputs so far of the run's stages or states after it.
func (*Client) Submit ¶ added in v0.17.0
Submit records a tree at its prefix. Each machine of the tree is written among the message's uploads, a bounded number at a time, and then the submit is sent. A file with a problem is sent as one, and its location keeps what was recorded before. It gives the name of the message, by which its receipt is found.
func (*Client) Taken ¶ added in v0.17.0
Taken stays until a run this client started has been taken up: it is no longer waiting to start. A run is waited for while a controller may take its start: for the life it was sent with, a few minutes if none, and the allowance for clocks.
func (*Client) Tickets ¶ added in v0.2.0
Tickets gives the tickets a run is waiting on, each name with its value. The value is the whole right to answer; it is in the record, which only the client of the run's tree and the clients its file's read: lists can read.
func (*Client) Undelivered ¶ added in v0.46.0
func (c *Client) Undelivered(ctx context.Context) ([]Undelivered, error)
Undelivered gives each send that was not delivered, from the record of every run this client lists and of everything below each: a send the step that sent it knew would not be delivered, and one the controller noted afterwards.
func (*Client) Wait ¶
Wait stays until a run has ended and gives it. It looks again when the store reports a write, and otherwise at the interval; a look that cannot reach the store is made again. A wait that is cut short, by the context's limit or by its caller going away, gives the run as it stands.
func (*Client) WaitReceipt ¶
func (c *Client) WaitReceipt(ctx context.Context, message string, life, interval time.Duration) (*instance.Receipt, error)
WaitReceipt stays until the controller has answered a message this client has just sent, and gives the receipt. life is the life the message was sent with. Once no controller may take the message and no receipt has come, the wait ends, saying the message was not taken up. It looks again when the store reports a write, and otherwise at the interval.
func (*Client) Watch ¶
func (c *Client) Watch(ctx context.Context, filter Filter, interval time.Duration, tell func(Update)) error
Watch follows a listing as it changes: the runs that already exist, then the mark, then each run that appears or changes, until the context ends. A run is given once more when it ends, saying how, also when the listing does not take in the finished. A run that the listing keeps, and that started and ended between two looks, is given once, as new and ended. It writes nothing and asks nothing of the controller. A look that cannot reach the store is made again at the next interval, and nothing is given on its account.
type Entry ¶
type Entry struct {
ID string `json:"id"` // the instance whose record it is in
Time time.Time `json:"time"`
// For a step.
Step int `json:"step,omitzero"`
Events []instance.Arrived `json:"events,omitzero"`
Asks []instance.Ask `json:"asks,omitzero"`
Status string `json:"status,omitzero"`
Shown machine.Shown `json:"state,omitzero"` // the run's state after the step
// For an emit.
Job string `json:"job,omitzero"` // the job that emitted
Name string `json:"name,omitzero"`
Data any `json:"data,omitzero"`
}
An Entry is one entry of a run's record as a follower is given it: a step, or a value a job emitted. Values are as they are shown: a blob is its type, its size and the path to ask for it by.
type Expect ¶ added in v0.46.0
type Expect struct {
Status string `yaml:"status"` // done by default
Failure string `yaml:"failure"` // error, timeout or denied
Output yaml.Node `yaml:"output"`
Error Texts `yaml:"error"` // texts the error holds
Refused Texts `yaml:"refused"` // texts the refusal of the definition holds
Record []*Look `yaml:"record"`
}
Expect is how the run should end, or that it is refused before it runs.
type File ¶
type File struct {
Name string `json:"name,omitzero"`
Type string `json:"type"`
Size int64 `json:"size"`
}
A File is a blob of a run as it is shown: what it is and how large, and no key. Name is what the value that holds it calls it.
type Filter ¶
type Filter struct {
// Labels keeps runs that carry every one of these.
Labels []Label
// Status keeps runs with this status.
Status string
// Parent keeps the runs this instance started.
Parent string
// Location keeps the runs at a location.
Location string
// Key keeps the runs of a keyed location with this key.
Key string
// Finished takes in the runs that have ended and are still kept. A
// Status of a run that has ended takes them in as well.
Finished bool
}
A Filter narrows a listing of runs, or widens it to take in those that have ended.
type InputFile ¶
An InputFile is a file given as input: the name it has as a file, from which the blob's type follows, and its contents.
func (InputFile) MarshalJSON ¶ added in v0.7.0
MarshalJSON refuses a file that Start cannot find in the input: one that is not an InputFile in a map[string]any or a []any.
type Label ¶ added in v0.46.0
type Label struct {
Name, Value string
// Valued is a label written with "=". In a listing it keeps only the
// runs whose label has that value, and a name alone keeps any value.
Valued bool
}
A Label is one label as it is written: a name, or name=value.
func ParseLabels ¶ added in v0.46.0
ParseLabels reads labels as they are written, each name once.
type Local ¶
type Local struct {
*Client
Memory *store.Memory
Controller *controller.Controller
Runner *runner.Runner
// contains filtered or unexported fields
}
Local is every role in one process with the store in memory: a controller, a runner and a client that trust each other. It is the same loop as on a computer, and each role works under its own row of the table of who may touch what. Nothing is set up beforehand and nothing is left behind.
func NewLocal ¶
func NewLocal(ctx context.Context, ceiling permission.Layer, report func(role string, err error)) (*Local, error)
NewLocal starts a controller and a runner in this process. The ceiling is what jobs may do on this computer. report is told of each pass of a role that failed.
func (*Local) Idle ¶ added in v0.46.0
Idle and Timed say, between two passes of the controller, whether nothing but a message can move any run, and whether no job runs and nothing but the clock or a message can move any run.
func (*Local) MoveClock ¶ added in v0.46.0
MoveClock moves the clock of every role in this process on, and wakes the controller to act on what is due.
func (*Local) Now ¶ added in v0.46.0
Now is the clock of every role in this process: the computer's, moved on as SetClock and MoveClock say.
func (*Local) Run ¶ added in v0.17.0
Run submits a definition as a tree of one file, at a prefix of its own that begins with the machine's name, and gives the run RunTree gives.
func (*Local) RunTree ¶ added in v0.17.0
RunTree submits a tree and gives the run at one of its locations: the one the submit starts for a singleton, and otherwise one started there with what start carries. A start that carries anything but its life to a singleton is an error.
func (*Local) SetClock ¶ added in v0.46.0
SetClock sets the clock of every role in this process to a time, from which it goes on.
func (*Local) SetSecret ¶ added in v0.17.0
SetSecret sets a secret at a location, as the controller's owner does.
func (*Local) SetValue ¶ added in v0.17.0
SetValue sets a value at a location, as the controller's owner does.
func (*Local) Still ¶ added in v0.46.0
Still says whether nothing can move any run in the store: the controller has nothing to do but housekeeping, and no run waits on a ticket. Only a client sends an event or an answer from outside the runs, and this process's client sends none after its start; each job on the runner has a wake for when its result is due.
func (*Local) WhileMoving ¶ added in v0.46.0
WhileMoving gives a context that ends once nothing can move any run, with ErrStill as its cause, or once a look at the store fails, with its error.
type Look ¶ added in v0.46.0
type Look struct {
Machine string `yaml:"machine" json:"machine,omitempty"`
Status string `yaml:"status" json:"status,omitempty"` // every run of the machine ended so
Event map[string]any `yaml:"event" json:"event,omitempty"` // a run of it was given such an event
Ask map[string]any `yaml:"ask" json:"ask,omitempty"` // a step of it asked for this
Emit map[string]any `yaml:"emit" json:"emit,omitempty"` // a job of it emitted this
Order []string `yaml:"order" json:"order,omitempty"` // of the events so named, it was given these, in order
Absent bool `yaml:"absent" json:"absent,omitempty"` // there is no such event, ask or emit
Finding string `yaml:"finding" json:"finding,omitempty"` // the check fails, as a finding says
// NotBefore is an event the ask looked for comes after, if at all.
NotBefore map[string]any `yaml:"not_before" json:"not_before,omitempty"`
}
A Look is one thing looked for in the record of the runs of a case.
type Machine ¶ added in v0.12.0
type Machine struct {
Path string // from the directory, such as devices/boiler.yaml
Location string // such as /home/devices/boiler
Draft *machine.Draft
Problem error // what stopped the file being read; Draft is nil
}
A Machine is one *.yaml file of a tree.
type Reply ¶ added in v0.47.0
type Reply struct {
Text string `yaml:"text" json:"text,omitzero"`
Calls []Call `yaml:"calls" json:"calls,omitzero"`
}
A Reply is the model's reply for one turn: its text and the tools it calls.
type Result ¶ added in v0.46.0
type Result struct {
Case string `json:"case"`
Outcome string `json:"outcome"`
Why []string `json:"why,omitzero"`
}
A Result is how a case went: ok, fails or finding, and why.
type Run ¶
type Run struct {
ID string `json:"id"`
Machine string `json:"machine,omitzero"`
Type string `json:"type,omitzero"`
// Status is waiting (to start), running, done, failed or cancelled.
Status string `json:"status"`
// Failure says why a failed run failed: error, timeout or denied.
Failure string `json:"failure,omitzero"`
Error string `json:"error,omitzero"`
// Thrown is where the script of the job that failed the run threw its
// error, as the job logged it: line 2, column 7, or lib.js line 2,
// column 9 in a file the script loads.
Thrown string `json:"thrown,omitzero"`
// A denial says what was refused, which layer refused it and what
// would fix it.
Refused string `json:"refused,omitzero"`
Layer string `json:"layer,omitzero"`
Fix string `json:"fix,omitzero"`
// Title, Input and Output are shown only to a client that reads the
// run's record.
Title string `json:"title,omitzero"`
Input any `json:"input,omitzero"`
Output any `json:"output,omitzero"`
// Used lists the permissions the run used: those of every job in it
// and below it.
Used []string `json:"used,omitzero"`
// State is a running run's state after its latest step: a flow's
// stages, a statechart's active states or an agent's turn, and the
// outputs so far.
State machine.Shown `json:"state,omitzero"`
Step int `json:"step,omitzero"`
Started time.Time `json:"started,omitzero"`
Ended time.Time `json:"ended,omitzero"`
Parent string `json:"parent,omitzero"`
// Location is where the run's machine lives, Key is the run's key at a
// keyed location, and Cause what started it: a step of another run, or
// a client's message.
Location string `json:"location,omitzero"`
Key string `json:"key,omitzero"`
Cause instance.Cause `json:"cause,omitzero"`
// Called is, for a start of a location in a tree another client owns,
// the run the call started there. The client is shown only its status
// and its output or error, from the call's result.
Called string `json:"called,omitzero"`
Jobs int `json:"jobs,omitzero"`
Timers int `json:"timers,omitzero"`
Tickets []string `json:"tickets,omitzero"`
Labels map[string]string `json:"labels,omitzero"`
}
A Run is a run as it is shown, wherever it is shown: the same shape and the same words at the command line, over HTTP and to an application.
type ScriptJob ¶ added in v0.7.0
type ScriptJob struct {
Allow, Deny []string
Timeout string // a length of time, such as 7s
Memory string // a size, such as 64MB
Tags []string
// Files are the files the script loads, each path as a job's files:
// writes it.
Files []string
}
ScriptJob is what a script wrapped by Script may do, and its limits, as a definition writes them on a job.
type StandIn ¶ added in v0.46.0
type StandIn struct {
Output yaml.Node `yaml:"output"`
Files map[string]string `yaml:"files"` // a blob of a file at each place of the output, by its path
Error *string `yaml:"error"`
Failure string `yaml:"failure"` // timeout or denied
Emit []Emitted `yaml:"emit"`
Replies []Reply `yaml:"replies"`
}
A StandIn is what a job gives in place of what it does: an output, an error, a failure the runner gives, or, for an agent's turn, the model's replies in order. Before an output or an error it emits each of Emit.
type Start ¶
type Start struct {
// At is the location the run is started at: the run's machine is the
// file recorded there.
At string
// Run is the run's name, if it was chosen beforehand with NewRun.
Run string
// Input is the run's input. An InputFile may stand in place of any
// value in a map[string]any or a []any of it: the file is put into the
// run's record, and stands in the input as a blob. A blob of another of
// this client's runs is carried over by writing it as it was shown, with
// the run it was shown for added: { "$blob": <its path>, "run": <that
// run's ID> }, with or without the type and size it was shown with. The
// blob is copied into the new run's record, and the copy stands in the
// input.
Input any
// Labels are the run's labels, each a name and its value, which may be
// empty. A name is 1 to 256 characters, with no whitespace and no "=".
Labels map[string]string
// Allow narrows what the run, and everything below it, may do.
Allow *permission.Layer
// Timeout is how long the run may take.
Timeout time.Duration
// Life is how long the start is good for; a few minutes if it says
// nothing.
Life time.Duration
}
A Start is what a start of a location carries.
type Step ¶ added in v0.46.0
type Step struct {
Reply *string `yaml:"reply"` // a ticket answered, with Value
Value any `yaml:"value"`
Send *string `yaml:"send"` // an event sent, with Data, to To or the step's run
Data any `yaml:"data"`
To string `yaml:"to"`
Cancel *bool `yaml:"cancel"`
Wait string `yaml:"wait"` // how far the clock moves on
Submit string `yaml:"submit"` // a directory submitted in place of the tree
Remove string `yaml:"remove"` // a file left out of the tree, submitted again
Values map[string]string `yaml:"values"` // values set, as the case's are
Secrets map[string]string `yaml:"secrets"` // secrets set, as the case's are
// The run the step acts on or waits for: the run tested, or with
// Machine the first run of that machine whose input holds Input. The
// step waits until it waits on Ticket or has Status.
Machine string `yaml:"machine"`
Input any `yaml:"input"`
Ticket string `yaml:"ticket"`
Status string `yaml:"status"`
// Refused is text the step's refusal holds: the step is to be refused.
Refused string `yaml:"refused"`
Finding string `yaml:"finding"`
// contains filtered or unexported fields
}
A Step is one thing a client does while the case runs, taken once it can be. A step with no action only waits.
type TestFile ¶ added in v0.46.0
type TestFile struct {
Path string `yaml:"-"`
Test string `yaml:"test"` // the machine or script tested
In string `yaml:"in"` // the directory of the tree it is in; by default it is alone
At string `yaml:"at"` // the tree's prefix, as corbie run submit --at gives it
Files []string `yaml:"files"` // a script's files:
Allow []string `yaml:"allow"` // the permissions a script's job is given
Cases []*Case `yaml:"-"` // in the order they are written
}
A TestFile is a file of cases, each a run of one machine or script and how it should end. Its paths are from the test file's directory.
func ReadTests ¶ added in v0.46.0
ReadTests reads a test file, and says everything wrong with it at once, a line for each.
func (*TestFile) Run ¶ added in v0.46.0
Run runs one case with every role in this process and the store in memory, as corbie test runs a machine, and says how it went. A case marked as a finding, or that has a check marked as one, is a finding while those checks fail as they say, and fails once they pass. report is told of each pass of a role that failed.
type Tree ¶ added in v0.17.0
type Tree struct {
Prefix string
// Directory is the directory's absolute path, every link followed. A
// machine reads it as run.context.
Directory string
Machines []*Machine
// Listed is each file and directory .corbieignore lists that the
// directory holds, from the directory, a directory ending in /.
Listed []string
// Tests is each test file of the directory, from the directory. A test
// file is no machine.
Tests []string
// Files is every file of the directory that was read, by its path from
// the directory: the machines, the scripts and the files they name, the
// files they include, and .corbieignore. A gateway is sent these.
Files map[string][]byte
// File is, for a tree of one file, that file's path from the directory.
File string
}
A Tree is a directory read to be submitted at a prefix: each of its *.yaml files that .corbieignore does not list is a machine at a location.
func ReadFile ¶ added in v0.17.0
ReadFile reads the file at rel in the context dir as a tree of its own, whose prefix at is the file's location. A script file is wrapped as Script wraps it, with job. A file that cannot be read as a machine is given with its Problem.
func ReadTree ¶ added in v0.17.0
ReadTree reads every *.yaml in dir and below it as a machine, but for .git, each test file and what the .corbieignore at the top of dir lists. A listed file and a test file have no location, and a machine may still read a listed file. at is the prefix, by default / and the directory's own name, and one that cannot be a prefix is an error, as is a line of .corbieignore that is no path in dir. A file that cannot be read as a machine, or whose path gives no location, is given with its Problem.
func (*Tree) Unsent ¶ added in v0.18.0
Unsent gives, by machine, each send and call of the tree's machines that the controller would refuse or not deliver, whatever else it holds: one to a location whose lifetime the address does not fit, or whose receive: does not list the sender, or for which the sender's own allow: and deny: do not hold send:. A send whose location is an expression or in another tree, or that names a run, is not checked, and neither is a list with an expression in it. empty gives each location of the tree with no machine that a send or a call names, with where: such a send may be one a condition leaves out, or wait for a file still to come.
type Undelivered ¶ added in v0.46.0
type Undelivered struct {
// Text names the event, where it was sent and why it was not delivered.
Text string
// Location is the location the send named, where the step that sent
// it knew the send would not be delivered.
Location string
}
An Undelivered is a send that the record of a run says was not delivered.
type Update ¶
type Update struct {
Run *Run `json:"run,omitzero"`
New bool `json:"new,omitzero"`
// Listed marks the end of the first listing: everything that already
// existed has been given.
Listed bool `json:"listed,omitzero"`
}
An Update is one thing a watcher of a listing is told: a run that is new or has changed, or the mark of the end of the first listing.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cli is Corbie's command line.
|
Package cli is Corbie's command line. |
|
Package gateway is the client package over HTTP: a route for each thing the package sends and each thing it reads, and streams for what can be followed.
|
Package gateway is the client package over HTTP: a route for each thing the package sends and each thing it reads, and streams for what can be followed. |