configreload

package
v0.1.0-rc.1 Latest Latest
Warning

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

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

Documentation

Overview

Package configreload implements the process-owned management HTTP adapter for explicit configuration reload and status (spec versioned-runtime-reloadable-proxy-configuration task 5.3; requirements 1.3, 1.7, 12.1-12.11, 13.1-13.2).

The listener is startup-fixed and loopback by default. Handlers never accept paths, YAML, URLs, commands, or plugin-install instructions. Authentication and browser-origin guards run before the reload coordinator is invoked. Accepted reload attempts continue under a host-owned context after client disconnect; terminal results remain available from status.

Index

Constants

View Source
const (
	ReloadPath = "/admin/config/reload"
	StatusPath = "/admin/config/status"
)

Fixed management paths (design Management API; req 12.3, 12.11).

View Source
const DefaultListenAddress = "127.0.0.1:9090"

DefaultListenAddress is the loopback-default management bind (req 12.2).

View Source
const DefaultMaxBodyBytes int64 = 64

DefaultMaxBodyBytes bounds reload request bodies (req 12.6-12.7).

View Source
const DefaultShutdownTimeout = 5 * time.Second

DefaultShutdownTimeout bounds management HTTP drain on Shutdown.

View Source
const MinBearerSecretRunes = 16

MinBearerSecretRunes is the minimum dedicated management bearer length (aligned with local API key floor; req 12.5-12.6).

Variables

This section is empty.

Functions

func HTTPStatusFor

func HTTPStatusFor(category sdkreload.ResultCategory) int

HTTPStatusFor maps a terminal result category to the management HTTP status (req 12.8).

Types

type AuthMode

type AuthMode string

AuthMode selects the startup-fixed management authentication posture.

const (
	// AuthModeLocalTrust permits unauthenticated local single-user loopback only.
	AuthModeLocalTrust AuthMode = "local_trust"
	// AuthModeBearer requires a dedicated Authorization: Bearer secret.
	AuthModeBearer AuthMode = "bearer"
	// AuthModeInjected requires a caller-supplied Authenticator.
	AuthModeInjected AuthMode = "injected"
)

type Authenticator

type Authenticator interface {
	Authorize(*http.Request) error
}

Authenticator is an optional injected administrator authenticator (req 12.5). Cookie-based browser authentication must not authorize reload.

type Handler

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

Handler serves fixed reload/status paths against a ReloadCoordinator.

func NewHandler

func NewHandler(opts Options, coord ReloadCoordinator) (*Handler, error)

NewHandler constructs the management HTTP handler. opts must already Validate.

func (*Handler) Mux

func (h *Handler) Mux() *http.ServeMux

Mux returns a ServeMux mounting only the fixed management paths.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP routes fixed reload and status paths only.

type Options

type Options struct {
	// Address is the management listen address. Empty defaults to DefaultListenAddress.
	Address string
	// AccessMode is the process access mode (single_user or multi_user).
	// Empty defaults to single_user.
	AccessMode accessmode.Mode
	// AuthMode selects authentication. Empty auto-selects local_trust only when
	// single_user + loopback; otherwise startup validation fails closed.
	AuthMode AuthMode
	// BearerToken is the dedicated management secret for AuthModeBearer.
	BearerToken string
	// Authenticator is required when AuthModeInjected.
	Authenticator Authenticator
	// AllowNonLoopback must be true to bind a non-loopback address (req 12.6).
	AllowNonLoopback bool
	// AllowOrigins is the exact Origin allowlist; default empty rejects all Origins (req 12.7).
	AllowOrigins map[string]struct{}
	// MaxBodyBytes bounds POST bodies; <=0 uses DefaultMaxBodyBytes.
	MaxBodyBytes int64
	// ShutdownTimeout bounds Server.Shutdown; <=0 uses DefaultShutdownTimeout.
	ShutdownTimeout time.Duration
}

Options configures the startup-fixed management server (req 12.11). Fields are process-owned; they are not taken from request bodies.

func (Options) Validate

func (o Options) Validate() error

Validate checks startup-fixed management posture (req 12.5-12.6, 12.11).

type ReloadCoordinator

type ReloadCoordinator interface {
	Reload(ctx context.Context, trigger sdkreload.Trigger) sdkreload.Result
	Status() sdkreload.Status
	// FixedSourcePath is the HTTP-only capability for the fixed startup source.
	// It must not appear on the canonical Status contract.
	FixedSourcePath() string
}

ReloadCoordinator is the narrow seam onto the runtimehost Coordinator. The management adapter never duplicates compile/prepare/publish logic.

type ResultDTO

type ResultDTO struct {
	Category           string   `json:"category"`
	AttemptID          int64    `json:"attempt_id"`
	ActiveGeneration   int64    `json:"active_generation"`
	PreviousGeneration int64    `json:"previous_generation,omitempty"`
	RestartFields      []string `json:"restart_required_fields,omitempty"`
	RestartFieldCount  int      `json:"restart_required_field_count,omitempty"`
	ReasonCategory     string   `json:"reason_category,omitempty"`
	CoalescedSignals   int64    `json:"coalesced_signals,omitempty"`
}

ResultDTO is the secret-safe JSON reload outcome (req 12.8, 12.10). It never carries YAML, credentials, DSNs, or configuration values. Domain validation/state lives in pkg/lipsdk/configreload; this is transport only.

type Server

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

Server is the process-owned management HTTP listener (req 12.1-12.2). Full host-wide shutdown ordering with the data plane is owned by task 5.6; this type still owns its own listen/serve/shutdown lifecycle.

func New

func New(opts Options, coord ReloadCoordinator) (*Server, error)

New constructs a validated management server around coord.

func (*Server) Addr

func (s *Server) Addr() string

Addr returns the bound address after Start, or the configured address before.

func (*Server) Handler

func (s *Server) Handler() http.Handler

Handler returns the management HTTP handler (for httptest without Listen).

func (*Server) Shutdown

func (s *Server) Shutdown(ctx context.Context) error

Shutdown stops the management listener with a bounded drain.

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

Start binds the startup-fixed listener and serves in a background worker.

type StatusDTO

type StatusDTO struct {
	ActiveGeneration    int64     `json:"active_generation"`
	LastResult          ResultDTO `json:"last_result"`
	LastSuccess         ResultDTO `json:"last_success,omitzero"`
	LastFailure         ResultDTO `json:"last_failure,omitzero"`
	SourceIntegrity     string    `json:"source_integrity,omitempty"`
	RetainedGenerations int       `json:"retained_generations,omitempty"`
	RetentionPressure   bool      `json:"retention_pressure,omitempty"`
	ControlDegraded     bool      `json:"control_degraded,omitempty"`
	ModelGeneration     string    `json:"model_generation,omitempty"`
	Busy                bool      `json:"busy"`
	FixedSourcePath     string    `json:"fixed_source_path"`
	PendingSignal       bool      `json:"pending_signal,omitempty"`
	CoalescedSignals    int64     `json:"coalesced_signals,omitempty"`
}

StatusDTO is the secret-safe JSON status snapshot (req 12.10, 13.1-13.2, 14.1, 14.8). FixedSourcePath is HTTP-transport-only and is not part of the canonical Status.

Jump to

Keyboard shortcuts

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