ether

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 8 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 ether manages the bus (the ether): an embedded NATS server, or a connection to an external cluster. The interface is the same for both modes - neither thrall nor lord can tell the difference, because both speak only NATS.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClientOptions

func ClientOptions(caPath, nkeySeed string) ([]nats.Option, error)

ClientOptions builds the nats options for a secured bus from credential paths: a CA the client verifies the server against and an nkey seed it authenticates with. An empty path adds no option, so an empty pair connects unsecured. Shared by the lord (via Config) and the operator CLI, so every client constructs the same options in one place.

Types

type Auth

type Auth struct {
	NkeySeed string `toml:"nkey_seed"`
}

Auth configures client authentication to an external bus. NkeySeed is the path to an nkey seed file the client signs the server nonce with. Empty = no auth.

type Config

type Config struct {
	Mode string `toml:"mode"` // "embedded" | "external"
	URL  string `toml:"url"`  // for external: "nats://a:4222,nats://b:4222"
	// StoreDir is the JetStream storage directory for the embedded server. Empty
	// (the default) uses an ephemeral temp dir removed on Stop; a fixed path keeps
	// the durable mailbox across a lord/process restart. Ignored in external mode.
	StoreDir string `toml:"store_dir"`
	TLS      TLS    `toml:"tls"`  // client-side transport security (external mode)
	Auth     Auth   `toml:"auth"` // client authentication (external mode)
	// Leaf, when present, makes the embedded server a leaf node of a central hub
	// (the spoke side of a hub-spoke topology). Valid only for embedded mode; nil =
	// a standalone embedded bus, as before.
	Leaf *Leaf `toml:"leaf"`
}

Config corresponds to the nats section in the manifest.

func (Config) Validate added in v0.7.0

func (c Config) Validate() error

Validate rejects a semantically broken nats config. It runs after the manifest applies defaults (so an empty Mode has already become "embedded"), and is the single place the bus config's validity lives - the manifest validation calls it. A leaf makes sense only for the embedded spoke; the hub side is external, bring-your-own NATS config.

type Ether

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

Ether holds the running bus and the system connection for the lord and registry.

func Start

func Start(ctx context.Context, cfg Config, opts ...StartOption) (*Ether, error)

Start brings up an embedded NATS server (default), or connects to an external URL.

func (*Ether) Conn

func (e *Ether) Conn() *nats.Conn

Conn returns the system NATS connection (lord, registry, observability).

func (*Ether) Stop

func (e *Ether) Stop()

Stop closes the connection and (in embedded mode) stops the server. An ephemeral store dir is removed; a persistent one (configured store_dir) is kept so the durable mailbox survives to the next start.

func (*Ether) URL

func (e *Ether) URL() string

URL returns the bus address; injected into thralls as AETHER_NATS_URL.

type Leaf added in v0.7.0

type Leaf struct {
	Remote string `toml:"remote"` // the hub's leafnode listener, e.g. "nats-leaf://hub.internal:7422"
	Site   string `toml:"site"`   // the account this node binds to = its isolation unit on the hub
	Domain string `toml:"domain"` // JetStream domain, unique per node (else the leaf's and hub's streams collide)
	// Credentials for the leaf link. User/Password suit a dev cluster (and may also be
	// embedded directly in Remote); Nkey is the path to an nkey seed file for production.
	User     string `toml:"user"`
	Password string `toml:"password"`
	Nkey     string `toml:"nkey"`
}

Leaf configures the embedded server as a NATS leaf node of a central hub. It binds this node's bus into a per-site account on the hub and gives its JetStream a per-node domain, closing the gap where an embedded bus could not be a spoke. aether owns only this spoke-side intent - which hub, which site, which JS domain, which credential; the hub side stays operator-authored NATS config (mode = "external").

type StartOption added in v0.7.0

type StartOption func(*startOptions)

StartOption tunes how the bus is brought up. Options carry runtime context the nats config alone does not - today the app name, which the leaf spoke exports as its data plane.

func WithApp added in v0.7.0

func WithApp(app string) StartOption

WithApp supplies the manifest's app name. It is required for an embedded leaf spoke (the export subject aether.<app>.> is otherwise undefined) and ignored by the other modes.

type TLS

type TLS struct {
	CA string `toml:"ca"`
}

TLS configures client-side transport security for an external bus. CA is the path to a PEM file used to verify the server's certificate (server TLS). Empty = no TLS.

Jump to

Keyboard shortcuts

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