app

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2026 License: Apache-2.0 Imports: 27 Imported by: 0

Documentation

Overview

Package app is beacon's composition root: it owns the store, bus manager, data server, supervisor, and admin HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type App

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

App is a running beacon instance: store, bus manager, data server, supervisor, and admin HTTP server, all started by Run and torn down by Close.

func Run

func Run(ctx context.Context, opts Options) (*App, error)

Run opens the store, seeds it if requested, starts the bus manager and data server, performs an initial supervisor reconcile, and starts the admin HTTP server (/health, /metrics, /api/, /mcp). It returns once everything is listening.

Components started by the supervisor's reconcile run on the supervisor's own background context, not ctx: ctx only bounds the Run call itself (the store open, the seed, the initial reconcile, and the admin listener bind). Call (*App).Close to stop everything Run started.

func (*App) AdminAddr

func (a *App) AdminAddr() string

AdminAddr returns the bound address of the admin server (/health, /metrics, /api/, /mcp).

func (*App) Close

func (a *App) Close(ctx context.Context) error

Close shuts the admin server down, stops the supervisor (which stops every running connector, sink, and source and flushes final queue checkpoints), stops the data server (unblocking any live SSE/WS streams), and closes the store. Safe to call once; a second call would double-close the store, so callers should not call Close twice.

func (*App) DataAddr

func (a *App) DataAddr() string

DataAddr returns the bound address of the data server (sink endpoints).

func (*App) Reconcile

func (a *App) Reconcile(ctx context.Context) error

Reconcile re-converges running components with stored config (Phase 2 API hook: hot config apply will call this after writing to the store).

func (*App) Service

func (a *App) Service() *config.Service

Service returns the config service layer: the single validation+persist+reconcile choke point that the HTTP config API (Phase 2 Task 4) and, later, the Phase 3 UI sit on instead of touching the store directly.

func (*App) Stats

func (a *App) Stats() *stats.Registry

Stats returns the live per-connector stats registry (Phase 2 API hook: serves rate/throughput data to the config API and, later, the UI dashboard).

type Options

type Options struct {
	DBPath       string
	DataAddr     string
	AdminAddr    string
	SeedPath     string
	Version      string // embedded in the config API's OpenAPI document; defaults to "dev"
	Log          *slog.Logger
	N2KBus       n2k.Bus
	ExtraN2KOpts []n2k.Option
}

Options configures a Run. DBPath, DataAddr, and AdminAddr are required; SeedPath, Version, N2KBus (simulation/embedding), and ExtraN2KOpts are optional.

Jump to

Keyboard shortcuts

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