app

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 17, 2026 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package app is the composition root.

It is the only package that imports concrete implementations and wires them together: loading configuration, constructing the registry, assembling the per-call pipeline from its stages, and starting the edge server. Keeping the wiring here lets every other package depend only on domain interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Gateway

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

Gateway is a fully wired, ready-to-run gateway. Build constructs it from a validated configuration; Run serves it until its context is cancelled and then shuts down gracefully.

func Build

func Build(cfg *config.Config, version string) (*Gateway, error)

Build wires the gateway from a validated configuration. It resolves connection-level secrets from the environment, builds a supervised, bounded pool per downstream and the session manager over them, constructs the security stages and the per-connection session factory, and assembles the client-facing HTTP server (the guarded MCP endpoint plus /metrics). It performs no network or subprocess I/O: downstream sessions open lazily on first use.

The configuration is assumed already validated by the config loader; Build still fails fast on a connection-level secret whose environment variable is unset, so an injected credential is never silently empty.

func (*Gateway) Handler

func (g *Gateway) Handler() http.Handler

Handler returns the gateway's root HTTP handler (the guarded MCP endpoint plus /metrics). It is exposed so the gateway can be exercised over httptest without binding a real listener.

func (*Gateway) Reload

func (g *Gateway) Reload(newCfg *config.Config) error

Reload applies a configuration reload (SIGHUP / file-watch). Only the client auth map and the policy rules are hot-reloaded — atomically, behind each engine's lock, so no live session or request is dropped (design §5). The reload is rejected as a whole if the new configuration is invalid, so a bad edit never takes down the running gateway. Downstream topology, redaction, and audit changes are restart-required; if any changed, the reload still applies the client + policy parts and logs that a restart is needed for the rest.

func (*Gateway) Run

func (g *Gateway) Run(ctx context.Context) error

Run serves the gateway until ctx is cancelled, then shuts down gracefully. It returns a non-nil error only if the server fails to start; a clean shutdown returns nil.

func (*Gateway) Shutdown

func (g *Gateway) Shutdown() error

Shutdown stops accepting requests, drains in-flight calls within the grace window, then tears down in the order the lifecycle requires (design §5): stop the HTTP server first so no new call enters, then close the downstream pools, then drain and fsync the audit writer last, after every producer has stopped. It returns the first error encountered and is safe to call more than once.

Jump to

Keyboard shortcuts

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