Documentation
¶
Overview ¶
Package delivery works out which run a message sent to an address goes to, and writes it there. A caller reads the facts once, decides each sending from them while writing nothing, and carries out each answer later:
- Facts.Read reads what the store says of each address, side by side. Facts.Missing gives the addresses not read yet.
- Decide answers a sending from an attempt's view of those facts, Facts.Step: the run it goes to, a run it starts, or why it is not delivered. It reads nothing, and answers the same on the same facts.
- Reserve writes the key's file of each run a step's answers start, side by side.
- Carry writes the blobs an event names, then its message, one answer at a time in the order asked; or it tells the sender why it was not delivered.
Start writes a singleton's start for a submit: the key's file, then the message. Move moves on an event that the run its message names cannot take, and Refuse tells the sender of a message no run took why. Take takes a run's key's file at its first step, and Free deletes it as the run ends.
A sender is told why its send or its call was not delivered one way for each kind of sender:
a send action a note in its record, <message>.note a send job, before it is sent the job fails, <message>.failed a send job, after it is done a note in its record, <message>.note a call job the job fails, <message>.failed a client its receipt
Index ¶
- func AddressText(a *machine.Address) string
- func Carry(ctx context.Context, env Env, o Origin, ask *run.Ask) error
- func Decide(ctl *identity.Identity, now time.Time, f *Facts, a Sending) (run.Ask, error)
- func Free(ctx context.Context, env Env, id string, st *run.State) error
- func Move(ctx context.Context, env Env, m Sent) error
- func NotDelivered(msg *run.Message, why string) string
- func NothingAt(at string) string
- func Refuse(ctx context.Context, env Env, m Sent, why string) error
- func Reserve(ctx context.Context, env Env, asks []run.Ask) error
- func SingletonRun(client string, sent time.Time, message, location string) string
- func Start(ctx context.Context, env Env, o Origin, s Singleton) error
- func Take(ctx context.Context, env Env, c *Claim) (holder, why string, err error)
- func TooLarge(size int) string
- type Claim
- type Env
- type Facts
- func (f *Facts) Callable(at string, sender machine.Address) (*Location, *machine.Definition, string)
- func (f *Facts) Client(to machine.Address) string
- func (f *Facts) Missing(to []machine.Address) []machine.Address
- func (f *Facts) Read(ctx context.Context, env Env, to []machine.Address) error
- func (f *Facts) Step() Facts
- type Location
- type Origin
- type Place
- type Receiver
- type Sending
- type Sent
- type Singleton
- type Target
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddressText ¶
AddressText writes an address as a note shows it: /loc, /loc#key, the run, or client:<name>.
func Carry ¶
Carry carries out what Decide answered for an origin, once Reserve has written the key's file of a run it starts: it copies the blobs the event names into the receiving run's record, then writes the message, and a send job's result after it. A send or a call not delivered, or whose message cannot be written, is refused to its sender. Every write is only-if-new or only-if-unchanged, under a name the answer gives, so Carry done again changes nothing.
func Decide ¶
Decide answers a sending from the facts, as the step records it: the run it goes to (To), a run it starts (Run), or why it is not delivered (Undelivered and Text). A call that starts a run of a transient location goes to no run already there, and has no To. A run it starts is noted in the facts, for the attempt's later sendings. It reads and writes nothing: the controller's identity and the time sign the message it measures.
func Free ¶
Free deletes the key's file a run holds, where it still names the run, as the run ends: a file left would count against limits: { runs }.
func Move ¶
Move moves on an event sent to a singleton's { at } or to { at, key } that the run its message names cannot take: the run has ended, never began, or lost the key to another.
- It reads the key's file, the location's file, and whether the run the message names and the run its start names have begun.
- It names the run that has the key now or, with none at a keyed location, the run the event starts: the run it was sent to, where that never began, or a fresh one named from the message and the run it moves from. It checks limits: { runs }, receive: and the size of the message, as Decide does, and refuses it to its sender where one fails.
- It writes the key's file of a run the event starts, then the blobs the event names, then the message in place, only-if-unchanged: it keeps its name, and sorts as it did.
- It notes in a run sender's record the run the event went to.
Where the run the message names has the key after all, or is about to start with it, Move writes nothing: that run takes it in the next pass.
func NotDelivered ¶
NotDelivered is the note that tells the sender of a message why it was not delivered.
func NothingAt ¶
NothingAt is why a send, a call or a start goes to no run at a location with no file.
func Refuse ¶
Refuse tells the sender of a message written for a send or a call, which no run takes, why it was not delivered, and deletes the message only-if-unchanged. A send job ended done once its event was written, and is told by a note. The key's file written for a run the message would start is deleted first: that run never begins.
The sender is told first and the message deleted after, so a stop between the two leaves no sender without its answer. A run's event to { at } or { at, key } is the one exception: another copy may have moved it on, so it is deleted first, and its sender told only where it was.
func Reserve ¶
Reserve writes the key's file of each run the answers of a step start at a key, side by side, before Carry writes any of their messages: a later send to the key finds that run. It reserves for a step's calls of a keyed location and its send jobs as well.
func SingletonRun ¶
SingletonRun names the run of a location's singleton that a submit starts, from the client's message: its sent time and its name.
func Start ¶
Start starts a singleton for a submit, the origin: it writes the key's file, which names the run and the runs it waits for, then the message that starts it, a root of its location under the origin's name. Every write is only-if-new or only-if-unchanged, so Start done again changes nothing: one stopped between the two writes finds the runs it waits for in the file.
func Take ¶
Take takes a key's file for a run at its first step, once the step is worked out and before it is written, so a run that loses has done nothing. A file that names the run already is its own. It gives the run that has the key where that is another, or why the run does not start: its location is at its limit, its own file uncounted.
Types ¶
type Claim ¶
type Claim struct {
// contains filtered or unexported fields
}
A Claim is the key's file a run takes at its first step.
type Env ¶
type Env struct {
Store store.Store
ID *identity.Identity
// Now signs what is written. It names no run and seeds none.
Now time.Time
// SideBySide is how many reads are made at once.
SideBySide int
}
An Env is the controller's store and identity, and its clock for signing.
type Facts ¶
type Facts struct {
// Places gives each { at } and { at, key } read.
Places map[Place]*Target
// Runs gives each run named by its ID that was read: nil where it is
// not running, or has no step.
Runs map[string]*Receiver
// contains filtered or unexported fields
}
Facts are what the store says of each address a step sends to or calls, read once, and the runs one attempt at the step starts.
func (*Facts) Callable ¶
func (f *Facts) Callable(at string, sender machine.Address) (*Location, *machine.Definition, string)
Callable gives what is recorded at { at } and its definition, as the facts read them, where a call from the sender would be taken whatever its input; or why it would not be: nothing is recorded there, its definition cannot be read, or its receive: does not list the sender.
func (*Facts) Client ¶
Client gives the client whose tree an address is in, as the facts read it: a run's own client for a run named by its ID, the client of the tree recorded at any other location, and "" where nothing is recorded.
func (*Facts) Missing ¶
Missing gives the addresses Read would read that the facts do not hold, each once, in the order given. It reads nothing.
func (*Facts) Read ¶
Read reads what the store says of each address the facts do not hold yet, side by side and once for each. A client's address, one that names no location or no key, and the address of a call, are not read: Decide refuses the first two before it looks, and the caller finds the call. A run named by its ID is read whatever location the address names.
type Location ¶
type Location struct {
Tree string `json:"tree"`
Client string `json:"client"`
Definition blob.Ref `json:"definition"`
Hash string `json:"hash"`
Lifetime string `json:"lifetime"`
// Runs is how many runs of a keyed or transient file may be running at
// once: no limit where it is none.
Runs int `json:"runs,omitzero"`
}
A Location is the file a submit records at a location: the tree and its client, the definition, and how runs start there.
type Origin ¶
type Origin struct {
// From is the sender: a run's address, or a client.
From machine.Address
// Cause is the step that asks, or the client's message.
Cause run.Cause
// Time and Name name a run the sending starts: the step's time, or the
// client's message's sent time, and the name of the message the
// sending writes.
Time time.Time
Name string
// Seed seeds a run the sending starts, and Depth is the sender's depth: a
// client has none, and a run it starts is at the top.
Seed []byte
Depth int
}
An Origin is what asks for a delivery, from which a run it starts is named and seeded: a run's step, or a client's message.
type Place ¶
type Place struct{ At, Key string }
A Place is one key at one location: the empty key for { at }.
type Receiver ¶
type Receiver struct {
ID, Location, Tree string
// Definition is nil where it cannot be read: the run fails as it reads
// it, and nothing is checked here.
Definition *machine.Definition
}
A Receiver is a run an event goes to, as the event is checked against it: a running run with the definition it started with, or a run about to start with its location's file.
func (*Receiver) Refuses ¶
Refuses says why the receiver does not take an event sent to it by its address, or "": it is at another location, its type takes no sent event, the event has a name of Corbie's or of its own, or its receive: does not list the sender. The tree's own client names a run of its own by its ID alone, and is always listed.
type Sending ¶
type Sending struct {
Origin Origin
To machine.Address
// Event is what a send gives. A call gives the event call, its data the
// call job's input.
Event *machine.Event
// Job is the send job or the call job that asks, and Name its full
// name: a refusal fails it. A send action has none, and a refusal of
// it is noted in the sender's record. A client's call is a call job
// with no name, which its receipt answers.
Job *machine.Job
Name string
}
A Sending is an event an origin sends to an address, or a call it makes there. A send to the address of a call, with its job, answers that call: Decide checks only its address, and the caller finds the call.
type Sent ¶
type Sent struct {
// Name is the message's full name, and Mark the mark it was read with.
Name string
Mark store.Mark
// Time is when the message was written.
Time time.Time
Message *run.Message
}
A Sent is a message written for a send or a call, as it waits in the controller's own inbox.
type Singleton ¶
type Singleton struct {
Run, Location string
// Restart says the run replaces the run that has the key. Any other
// start leaves that run the key, and loses as it begins.
Restart bool
// Cancelled are the runs at the location the submit cancelled, which
// the run waits for. With none, it waits for the run that has the key,
// and for those that run waits for.
Cancelled []string
}
A Singleton is the run of a location's singleton that a submit starts.
type Target ¶
type Target struct {
// Holder is the run the key's file names, or none.
Holder string
// Running is the holder as an event is checked against it, where it is
// running, and Waiting says it has no step and its start is waiting.
Running *Receiver
Waiting bool
// File is the location's file, or nil with none, and Definition the
// definition it names, or nil where that cannot be read.
File *Location
Definition *machine.Definition
// Runs is how many key files the location has, where File has
// limits: { runs } and no run holds the key.
Runs int
}
A Target is what the store says of a place.