lord

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: MIT Imports: 27 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 lord implements the supervisor: it reads the manifest, spawns thralls as OS processes, watches them and restarts them per strategy (one_for_one / one_for_all / rest_for_one). Restart decisions go through a SINGLE supervisor loop, so there are no races; stale exit events are recognized by the process generation.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Edge

type Edge struct {
	HTTP []EdgeHTTPSpec `toml:"http"` // [[edge.http]] - HTTP ingress servers
}

Edge groups the built-in edge servers: processes whose input arrives from outside the ether (a push, e.g. HTTP) rather than from a mailbox (a pull). Each edge is spawned and supervised as an ordinary thrall; the runtime that translates the external protocol into ether call/cast is built into the aether binary (the internal `_edge` subcommand), so it does not multiply across the language SDKs.

type EdgeHTTPSpec

type EdgeHTTPSpec struct {
	Name string `toml:"name"` // unique name; the edge is supervised under it
	Addr string `toml:"addr"` // host:port to bind (e.g. ":8080")
	// Routes maps a "METHOD /path" key to a target thrall operation, e.g.
	//   route."POST /increment" = { thrall = "counter", op = "increment", kind = "cast" }
	Routes map[string]EdgeRoute `toml:"route"`
}

EdgeHTTPSpec = one HTTP ingress server. It binds a single OS port (singleton fit) and maps HTTP routes to a thrall operation over the ether.

type EdgeRoute

type EdgeRoute struct {
	Thrall string `toml:"thrall"` // target thrall name
	Op     string `toml:"op"`     // operation invoked on the thrall
	Kind   string `toml:"kind"`   // call (wait for reply -> body) | cast (fire-and-forget -> 202); default call
	// Schema is an optional path to a JSON Schema (relative to the manifest). When set, the edge
	// validates the request body against it and rejects a malformed body with a 400 before the
	// message reaches the ether. Empty = today's "is it valid JSON" check only.
	Schema string `toml:"schema"`
	// contains filtered or unexported fields
}

EdgeRoute = a single HTTP route's target on the ether.

type Intensity

type Intensity struct {
	Max      int `toml:"max"`
	WithinMs int `toml:"within_ms"`
}

Intensity = the restart-intensity window (max restarts within a given time).

type Liveness

type Liveness struct {
	HeartbeatIntervalMs int `toml:"heartbeat_interval_ms"` // how often a thrall heartbeats (default 2000)
	StaleAfterMisses    int `toml:"stale_after_misses"`    // missed intervals before "stale" (default 3)
}

Liveness tunes how fast a hung-but-alive thrall is detected. The interval is propagated to the thralls (they heartbeat at it) and the lord derives its reaper threshold from the same values, so the two never drift. Defaults preserve the historical 2s / 3 misses (~6s).

type Lord

type Lord struct {
	// contains filtered or unexported fields
}

Lord supervises a set of thralls under a single strategy (a supervision node).

func New

func New(m *Manifest, eth *ether.Ether) (*Lord, error)

New creates the root lord from a manifest.

func (*Lord) Start

func (l *Lord) Start(ctx context.Context) error

Start provisions durable mailboxes, starts the supervisor loop, the heartbeat consumer and the thralls.

func (*Lord) Stop

func (l *Lord) Stop()

Stop performs a graceful drain of all thralls.

type Manifest

type Manifest struct {
	App              string        `toml:"app"`
	Strategy         string        `toml:"strategy"` // one_for_one | one_for_all | rest_for_one
	RestartIntensity Intensity     `toml:"restart_intensity"`
	Nats             ether.Config  `toml:"nats"`
	Observability    Observability `toml:"observability"`
	Liveness         Liveness      `toml:"liveness"`
	Thralls          []ThrallSpec  `toml:"thrall"`
	Edge             Edge          `toml:"edge"`
}

Manifest = the contents of aether.toml (the supervision tree topology).

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads, parses, fills in the defaults and validates aether.toml.

type Observability

type Observability struct {
	MetricsAddr string `toml:"metrics_addr"` // host:port for the Prometheus /metrics endpoint (empty = disabled)
	// Dashboard serves the read-only observer dashboard (live supervision tree + event stream)
	// on the same HTTP server as /metrics; it therefore requires MetricsAddr. Off by default.
	Dashboard bool `toml:"dashboard"`
}

Observability configures the runtime's telemetry. An empty MetricsAddr keeps the Prometheus endpoint off (opt-in), so plain runs stay free of an open HTTP port.

type RestartDecision

type RestartDecision int

RestartDecision determines what to do after a thrall exits.

const (
	DontRestart RestartDecision = iota
	RestartOne
	RestartAll  // one_for_all
	RestartRest // rest_for_one
)

type ThrallSpec

type ThrallSpec struct {
	Name     string `toml:"name"`
	Cmd      string `toml:"cmd"`
	Restart  string `toml:"restart"`  // permanent | transient | temporary
	Scope    string `toml:"scope"`    // local | singleton
	Replicas int    `toml:"replicas"` // >1 -> queue group (a pool of workers)
	Durable  bool   `toml:"durable"`  // true -> casts go through JetStream (survive a crash)

	// EventLog opts the thrall into an event-sourcing log: a separate RETENTION stream the
	// thrall appends events to and replays in init to rebuild state. Independent of Durable.
	EventLog         bool  `toml:"event_log"`
	EventLogMaxMsgs  int64 `toml:"event_log_max_msgs"`   // 0 = unbounded (message count)
	EventLogMaxAgeMs int64 `toml:"event_log_max_age_ms"` // 0 = unbounded (age)
	// EventLogDedupWindowMs bounds how long JetStream remembers a Nats-Msg-Id for dedup. 0 uses
	// wire.DefaultEventLogDedupWindowMs. Raise it if command-key idempotence must survive slow
	// retries (the trade-off is a larger dedup index).
	EventLogDedupWindowMs int64 `toml:"event_log_dedup_window_ms"`

	// Fencing opts the thrall out of lord-liveness fencing when set to false (a *bool so an unset
	// field defaults to on). By default every thrall self-terminates when it can no longer verify
	// its lord's KV lease (AE-031); on a shared external bus a KV hiccup then reaps the whole tree.
	// Set fencing = false for a thrall whose orphan is harmless (a stateless / read-only poller) so
	// a bus blip does not take it down - at the cost that it MAY outlive its lord. It does not
	// affect singleton fencing (a singleton still self-exits on losing its lock).
	Fencing *bool `toml:"fencing"`

	// EventLogUse declares what the event log is for, so the lord can turn the retention footgun
	// (a bound truncates a replayed log - there is no snapshot) from a warning into an invariant:
	// "rebuild" + a retention bound is a config error (fail-fast); "audit" + a bound is fine (no
	// warning). Unset keeps today's warning. Values: "" | "rebuild" | "audit".
	EventLogUse string `toml:"event_log_use"`
}

ThrallSpec = a single child in the manifest.

Jump to

Keyboard shortcuts

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