Documentation
¶
Overview ¶
Package dispatch is the queued|dispatching|delivered|uncertain file discipline, lifted out of nova-wake serve's own bookkeeping so that nova-chat takes it rather than re-spelling it (SPEC-CHAT work-list item 13).
One item is one row in a state file, keyed prefix+"<id>", holding the composed fields "<state>|<stamp>|attempt=<n>|rc=<n>". The states are:
queued the item is waiting to be dispatched dispatching the item is in flight; a kill before the outcome is uncertain delivered the receiver accepted it (exit 0) uncertain the outcome is unknown and a person's to resolve cc recorded for the line's attention, never a dispatch
An uncertain item blocks the queue: nothing behind it is dispatched until a person resolves it. This file only moves an item between states; the caller owns the spawn, the print and the remedy, which differ between a bus note and a Discord post.
Index ¶
- Constants
- type Ledger
- func (l *Ledger) CC(id, stamp string)
- func (l *Ledger) Has(id string) bool
- func (l *Ledger) IDs() []string
- func (l *Ledger) MarkDelivered(id, done string, rc int, redelivered bool)
- func (l *Ledger) MarkDispatching(id, stamp string, attempt int)
- func (l *Ledger) MarkUncertain(id, done string, attempt, rc int)
- func (l *Ledger) Queue(id, stamp string)
- func (l *Ledger) Record(id string) (state, stamp string, attempt, rc int)
- func (l *Ledger) Recover(id, stamp string, attempt int)
- func (l *Ledger) StateOf(id string) string
Constants ¶
const ( Queued = "queued" Dispatching = "dispatching" Delivered = "delivered" Uncertain = "uncertain" CC = "cc" )
The five states, spelled once so a reader needs one file.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Ledger ¶
type Ledger struct {
// contains filtered or unexported fields
}
Ledger is a keyed dispatch ledger over a wake.State. Each item is stored at prefix+"<id>", and every write is made through wake.Compose so the fields round-trip byte for byte.
func (*Ledger) MarkDelivered ¶
MarkDelivered writes delivered with the exit code, after the receiver returned 0. redelivered marks a person's retry (0 for a first dispatch).
func (*Ledger) MarkDispatching ¶
MarkDispatching writes dispatching with the attempt, before the spawn.
func (*Ledger) MarkUncertain ¶
MarkUncertain writes uncertain with the attempt and exit code, when the receiver did not accept the item. It stays unresolved until a person acts.
func (*Ledger) Queue ¶
Queue records id at queued. Use Queue for an item that must be acted on, CC for one that should be known.
func (*Ledger) Record ¶
Record returns the state, stamp, attempt and rc stored for id. A missing record is state "" and attempt forced to 1, matching a first attempt.