Documentation
¶
Overview ¶
Package wire defines the envelope and subject conventions shared with the SDKs. The Envelope shape must stay in sync with the TS side (sdk/ts/src/envelope.ts).
Index ¶
- Constants
- func Call(app, name string) string
- func Cast(app, name string) string
- func Ctl(name string) string
- func Data(app, name string) string
- func EventLog(app, name string) string
- func EventLogStream(app, name string) string
- func FleetHealth(app, lordID string) string
- func FleetHealthAll() string
- func Heartbeat(name string) string
- func HeartbeatAll() string
- func Info(app, name string) string
- func LordCtl() string
- func Stream(app, name string) string
- type Envelope
- type HeartbeatMetrics
- type Kind
- type SpawnReply
- type SpawnSpec
- type StopSpec
- type WireError
Constants ¶
const ( OpSpawn = "spawn" OpStop = "stop" )
Runtime supervision ops carried in a ctl envelope's Op field on the LordCtl channel (thrall -> lord). SpawnSpec is the payload for OpSpawn; StopSpec for OpStop.
const DedupHeader = "Nats-Msg-Id"
DedupHeader is the JetStream message header an Append carries to deduplicate an event within the event-log stream's duplicate window. Two Appends with the same value land as one message. It documents the dedup contract the SDKs mirror through their native APIs (Go nats.MsgId, TS msgID, Python an explicit Nats-Msg-Id header), which all resolve to this same header name.
const DefaultEventLogDedupWindowMs = 2 * 60 * 1000
DefaultEventLogDedupWindowMs is the event-log stream's duplicate window when the manifest does not set one. It matches the JetStream default (2 min) but is applied explicitly so the window is a deliberate, inspectable choice rather than an implicit server default.
const Events = "aether._lord.events"
Events = lifecycle stream (started/crashed/restarted) for the dashboard.
Variables ¶
This section is empty.
Functions ¶
func Data ¶
Data = wildcard across call/cast/info; a thrall puts a single subscription on it (one iterator = FIFO order, i.e. a serialized mailbox).
func EventLog ¶
EventLog = subject a thrall appends event-sourcing events to (opt-in). Unlike the WorkQueue mailbox, these are captured by a separate RETENTION stream (EventLogStream) and are therefore replayable in init to rebuild state ("log is truth, state is a projection").
Note: this subject is under the mailbox wildcard Data (`aether.<app>.<name>.*`), so a non-durable thrall receives its own appended events back on its data subscription; the mailbox dispatch ignores the "evt" verb (only call/cast are handled), so it is harmless - just a small self-echo. Durable thralls do not have the wildcard subscription and are unaffected.
func EventLogStream ¶
EventLogStream = name of the retention JetStream stream backing a thrall's event log.
func FleetHealth ¶ added in v0.8.0
Fleet observability: a curated health summary each lord publishes about itself, so a fleet-wide aggregator can show the whole network from one place. This is a deliberate sibling of the raw supervision channels above: `aether._lord.>` stays node-local and is never exported, whereas `aether._fleet.>` is the curated summary the operator explicitly exports/imports to build a fleet view. The lord's identity travels in the payload (app + lord id), not in the subject, so a lord id that contains dots (an FQDN hostname) does not have to be a single subject token.
func FleetHealthAll ¶ added in v0.8.0
func FleetHealthAll() string
FleetHealthAll = wildcard an aggregator subscribes to for every lord's health across the bus.
func HeartbeatAll ¶
func HeartbeatAll() string
HeartbeatAll = wildcard for the lord to listen to heartbeats of all thralls.
Types ¶
type Envelope ¶
type Envelope struct {
V int `json:"v"`
ID string `json:"id,omitempty"`
// Trace is a correlation id propagated across hops (call/cast chains), distinct from ID
// which correlates a single request with its reply. It lets one logical operation be
// followed across process boundaries; an edge (CLI, first message) mints it, handlers pass
// it to downstream calls, and it is logged so a trace and a log line can be joined.
Trace string `json:"trace,omitempty"`
Kind Kind `json:"kind"`
From string `json:"from,omitempty"`
To string `json:"to,omitempty"`
Op string `json:"op,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
Status string `json:"status,omitempty"` // reply: "ok" | "error"
Error *WireError `json:"error,omitempty"`
TS int64 `json:"ts,omitempty"`
}
Envelope is the uniform JSON envelope for all communication in the ether.
type HeartbeatMetrics ¶
type HeartbeatMetrics struct {
MailboxDepth int `json:"mailbox_depth"`
MailboxLatencyMs float64 `json:"mailbox_latency_ms"`
ProcessedTotal uint64 `json:"processed_total"`
}
HeartbeatMetrics are a thrall's self-reported runtime samples, carried in the payload of a heartbeat envelope. The lord aggregates them into the /metrics exposition. Field order is part of the wire contract - the TS and Python SDKs mirror it exactly.
mailbox_depth is the number of messages the thrall currently holds (received, handler not yet returned); mailbox_latency_ms is the duration of the most recent handler (including the wait for the serialized mailbox lock); processed_total is the cumulative count of handled messages since the thrall started (it resets on restart, like any process-local counter).
type SpawnReply ¶
type SpawnReply struct {
Name string `json:"name"`
}
SpawnReply is the reply payload for a successful spawn.
type SpawnSpec ¶
type SpawnSpec struct {
Name string `json:"name"`
Cmd string `json:"cmd"`
Restart string `json:"restart,omitempty"` // permanent | transient | temporary (default permanent)
Durable bool `json:"durable,omitempty"` // true -> casts go through JetStream
EventLog bool `json:"event_log,omitempty"` // true -> provision an event-sourcing log for Append/Rebuild
// EventLogDedupWindowMs sets the event-log stream's duplicate window (0 = default). Within it,
// two Appends carrying the same Nats-Msg-Id land as one message.
EventLogDedupWindowMs int64 `json:"event_log_dedup_window_ms,omitempty"`
}
SpawnSpec is the request payload to start a child at runtime - the subset of a manifest thrall relevant to a dynamic child. A dynamic child is always local scope and single instance; Replicas and Scope are not part of the runtime API.