app

package
v0.7.0-alpha.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Overview

Package app wires the backend together. Both the upstream main and downstream mains use it; downstreams pass extension options.

Index

Constants

View Source
const MemoryLimitEnv = "SNELLIUS_MEMORY_LIMIT"

MemoryLimitEnv holds the pod's memory limit in bytes; the chart sets it from limits.memory.

Variables

This section is empty.

Functions

func ApplyMemoryLimit

func ApplyMemoryLimit() int64

ApplyMemoryLimit sets the Go memory target to 90 % of the limit in MemoryLimitEnv (D-025). An explicit GOMEMLIMIT wins; a missing, zero or unparsable limit is ignored and logged. It returns the target set, or zero. Run calls it first; repeated calls are harmless.

func CoreCapabilities

func CoreCapabilities(snap *cache.Snapshot, d Diagnostics, collected collect.Snapshot) []api.Capability

CoreCapabilities returns the core inputs' states for /api/v1/meta; a syncing or unstarted watch, and proxy stats before their first round, have none.

func Run

func Run(ctx context.Context, kubeconfig string, o Options, opts ...extension.Option) error

Run is RunWith over extension.New(opts...): the core plus the kgateway pack.

func RunWith added in v0.6.0

func RunWith(ctx context.Context, kubeconfig string, o Options, reg *extension.Registry) error

RunWith builds clients from kubeconfig (or the in-cluster config when empty and running in a pod), then serves reg until ctx is done.

Types

type App

type App struct {
	Engine  *engine.Engine
	Handler http.Handler
	// contains filtered or unexported fields
}

App is a built, not yet started, backend.

func Build

func Build(c Clients, o Options, reg *extension.Registry) (*App, error)

Build resolves the served kinds and constructs every component. Both intervals must be positive and the delegation edge cap not negative.

func (*App) Start

func (a *App) Start(ctx context.Context)

Start runs the cache, the pack and extension collectors, the model loop and the served-kinds monitor until ctx is done. PollInterval is the loop's safety timer. The controller metrics collector starts as soon as the first install is discovered over a settled cache, so the first metrics do not wait for a tick.

type Clients

type Clients struct {
	Dynamic   dynamic.Interface
	Kube      kubernetes.Interface
	Discovery kinds.DiscoveryClient
	// Metadata reads CRD metadata; nil means no CRD watch.
	Metadata metadata.Interface
	// InCluster selects direct pod-IP metric scraping; otherwise pods/proxy is used.
	InCluster bool
	// Scraper overrides the metrics scraper InCluster selects; nil keeps it.
	Scraper ctrlmetrics.Scraper
}

Clients are the Kubernetes clients the app uses.

type Diagnostics

type Diagnostics struct {
	NoEvents, NoCRDs, NoProxyStats, NoEndpoints bool
	ControllerLogs                              bool
	// ControllerLogsNamespaces are the install namespaces whose controller logs are read.
	ControllerLogsNamespaces []string
}

Diagnostics toggles the optional inputs (design §18.1): No* turns off a default-on input, ControllerLogs turns on a default-off one.

type Options

type Options struct {
	// Listen is the HTTP address; empty means :8080 in-cluster and 127.0.0.1:8080 locally.
	Listen string
	// Pinned restricts the UI to one install: its ID, or namespace/name (D-016).
	Pinned string
	// PollInterval is the maximum time between model recomputes: the safety
	// timer. Object, access, metrics and served-kind changes recompute sooner (D-019).
	PollInterval time.Duration
	// MetricsInterval is the controller metrics scrape interval.
	MetricsInterval time.Duration
	// DelegationEdgeCap caps the selected delegation edges per install (rules
	// §5.7); zero means computed.DefaultBounds.Edges. A higher cap needs more
	// memory (D-025).
	DelegationEdgeCap int
	// KindsInterval is how often served kinds are re-resolved; zero means 60 s.
	KindsInterval time.Duration
	// UI is the single-page application served at /.
	UI fs.FS
	// ConfirmEvery is the engine's confirm tick interval; zero means
	// engine.ConfirmEvery. Tests only.
	ConfirmEvery time.Duration
	// OnLoop receives the engine's loop transitions. Tests only.
	OnLoop func(engine.LoopEvent)
	// Clock drives the engine and stamps snapshots and collected values; nil
	// means the real clock. Tests only.
	Clock clock.WithTicker
	// Diagnostics toggles the optional inputs; the zero value keeps the defaults.
	Diagnostics Diagnostics
	// ClassOnlyInstalls adds an install per GatewayClass controllerName that no
	// detector claims, known from Gateway API status alone.
	ClassOnlyInstalls bool
}

Options are the runtime settings.

Jump to

Keyboard shortcuts

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