delivery

package
v0.50.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 3, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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:

  1. Facts.Read reads what the store says of each address, side by side. Facts.Missing gives the addresses not read yet.
  2. 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.
  3. Reserve writes the key's file of each run a step's answers start, side by side.
  4. 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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddressText

func AddressText(a *machine.Address) string

AddressText writes an address as a note shows it: /loc, /loc#key, the run, or client:<name>.

func Carry

func Carry(ctx context.Context, env Env, o Origin, ask *run.Ask) error

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

func Decide(ctl *identity.Identity, now time.Time, f *Facts, a Sending) (run.Ask, error)

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

func Free(ctx context.Context, env Env, id string, st *run.State) error

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

func Move(ctx context.Context, env Env, m Sent) error

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.

  1. 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.
  2. 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.
  3. 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.
  4. 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

func NotDelivered(msg *run.Message, why string) string

NotDelivered is the note that tells the sender of a message why it was not delivered.

func NothingAt

func NothingAt(at string) string

NothingAt is why a send, a call or a start goes to no run at a location with no file.

func Refuse

func Refuse(ctx context.Context, env Env, m Sent, why string) error

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

func Reserve(ctx context.Context, env Env, asks []run.Ask) error

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

func SingletonRun(client string, sent time.Time, message, location string) string

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

func Start(ctx context.Context, env Env, o Origin, s Singleton) error

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

func Take(ctx context.Context, env Env, c *Claim) (holder, why string, err error)

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.

func TooLarge

func TooLarge(size int) string

TooLarge says why a message of a size cannot be written, or "".

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.

func Hold

func Hold(id string, st *run.State, start string, limit int) (*Claim, bool)

Hold gives the claim a run's first step makes, from the run's state and its definition's limits: { runs }, or nil where it makes none, and says whether the run is counted: a transient run whose definition limits its runs is, and takes a file under its own ID so its location counts it.

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

func (f *Facts) Client(to machine.Address) string

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

func (f *Facts) Missing(to []machine.Address) []machine.Address

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

func (f *Facts) Read(ctx context.Context, env Env, to []machine.Address) error

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.

func (*Facts) Step

func (f *Facts) Step() Facts

Step gives an attempt at a step its view of the facts: it shares what was read, and what it reads, and counts only the runs its own sendings start.

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.

func ReadLocation

func ReadLocation(ctx context.Context, s store.Store, id *identity.Identity, location string) (*Location, error)

ReadLocation reads the file recorded at a location with the controller's key: nil where there is none.

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

func (r *Receiver) Refuses(msg *run.Message) string

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL