dispatch

package
v0.16.0-dev.c839379e Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2026 License: MIT Imports: 3 Imported by: 0

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

View Source
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 New

func New(st *wake.State, prefix string) *Ledger

New returns a Ledger over st, keying each item under prefix.

func (*Ledger) CC

func (l *Ledger) CC(id, stamp string)

CC records id at cc: counted, never a turn.

func (*Ledger) Has

func (l *Ledger) Has(id string) bool

Has reports whether id has a record.

func (*Ledger) IDs

func (l *Ledger) IDs() []string

IDs returns every id with a record, in key (sorted) order.

func (*Ledger) MarkDelivered

func (l *Ledger) MarkDelivered(id, done string, rc int, redelivered bool)

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

func (l *Ledger) MarkDispatching(id, stamp string, attempt int)

MarkDispatching writes dispatching with the attempt, before the spawn.

func (*Ledger) MarkUncertain

func (l *Ledger) MarkUncertain(id, done string, attempt, rc int)

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

func (l *Ledger) Queue(id, stamp string)

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

func (l *Ledger) Record(id string) (state, stamp string, attempt, rc int)

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.

func (*Ledger) Recover

func (l *Ledger) Recover(id, stamp string, attempt int)

Recover rewrites an interrupted dispatching as uncertain, keeping the attempt. It is called at start when a dispatching record is found.

func (*Ledger) StateOf

func (l *Ledger) StateOf(id string) string

StateOf returns the stored state for id.

Jump to

Keyboard shortcuts

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