node

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Aug 31, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package node assembles a running jetwayd from a configuration.

It exists so that there is exactly one wiring. jetwayd builds a node and serves it; the scenario suite builds a node and drives it. An integration test standing on a second, parallel copy of this assembly would be testing the copy -- and this repository has twice shipped tests that passed because they encoded the same assumption as the code they were checking.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

type Node struct {
	Config  *config.Config
	Log     *slog.Logger
	Store   store.Store
	Gateway *gateway.Gateway
	Bus     *gateway.Bus
	Queues  *queue.Manager
	Sweeper *queue.Sweeper
	Router  *egress.Router
	Spool   *spool.Spool
	Fleet   *demo.RunningFleet
	API     *api.Server
	// contains filtered or unexported fields
}

Node is an assembled gateway: store, links, queues, sweeper and console.

Everything a caller might want to drive or assert on is exported, because the scenario suite is a legitimate consumer rather than a special case that needs back doors cut for it.

func Build

func Build(ctx context.Context, cfg *config.Config, log *slog.Logger, opts Options) (*Node, error)

Build assembles a node without starting anything that accepts work.

Listeners bind here, so a port conflict or an unreadable certificate fails at build time rather than later in a goroutine where it reads as silence.

func (*Node) Addr

func (n *Node) Addr(listener string) string

Addr returns the address of the named TCP listener, which is how a test that asked for port 0 finds out what it got.

func (*Node) Close

func (n *Node) Close()

Close releases everything Build acquired. It is safe on a partly built node, which is what makes it usable on Build's own error paths.

func (*Node) Drain

func (n *Node) Drain(ctx context.Context, hs *http.Server)

Drain stops taking new work, lets what is in flight finish, then stops serving. Cutting links first would lose messages mid-pipeline.

func (*Node) Handler

func (n *Node) Handler() ingress.Handler

makeHandler builds the function every ingress calls. Handler is the ingress callback: it is what turns bytes off a link into a stored, parsed, applied message.

func (*Node) Listeners

func (n *Node) Listeners() []ingress.Ingress

Listeners returns the bound ingress listeners.

func (*Node) LivePeers

func (n *Node) LivePeers() []string

LivePeers names the partners currently holding a session.

func (*Node) Serve

func (n *Node) Serve(ctx context.Context, drainTimeout time.Duration) error

Serve runs the console until the context is cancelled.

func (*Node) Start

func (n *Node) Start(ctx context.Context) error

Start brings up everything that accepts or generates work, and returns once the links are running. It does not serve the console; Serve does that.

type Options

type Options struct {
	// LocatorSecret seeds record locator allocation. Required.
	LocatorSecret []byte
	// SkipConsole omits the HTTP server. A load run wants the pipeline, not
	// the console.
	SkipConsole bool
	// ExtendAPI is passed through to the console's mux, so an embedder can
	// serve its own pages from the node's one listener.
	ExtendAPI func(mux *http.ServeMux)
}

Options are the knobs the scenario suite needs and jetwayd does not.

Jump to

Keyboard shortcuts

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