core

package
v0.9.12 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 31 Imported by: 0

Documentation

Overview

pkg/core/server.go

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Flush added in v0.9.8

func Flush(w http.ResponseWriter) error

Flush pushes any buffered response bytes to the client immediately. It is keel's streaming-passthrough surface: a handler relaying an upstream stream (SSE or chunked) calls Flush after writing each event so the client receives it live rather than at end-of-response.

keel's middleware chain wraps the http.ResponseWriter (metrics, access log, OWASP body limit, OTel span), and those wrappers are not themselves http.Flushers — so a handler MUST NOT depend on a direct w.(http.Flusher) assertion. Flush goes through http.ResponseController, which traverses each wrapper's Unwrap to reach the connection's flusher. It returns an error only when the underlying transport genuinely cannot flush (e.g. a writer with no flusher in its chain).

func RunServer added in v0.9.6

func RunServer(srv *Server, ctx context.Context)

RunServer runs srv until ctx is cancelled. Fatal errors are handled internally by the server via its logger.

Types

type Option

type Option func(*Server)

func WithConfig

func WithConfig(cfg config.Config) Option

func WithConfigPaths

func WithConfigPaths(configPath, secretsPath string) Option

WithConfigPaths records the config and secrets file paths used by Reload. configPath and secretsPath may be empty strings if unused.

func WithDefaultRegistrar

func WithDefaultRegistrar() Option

func WithLogger

func WithLogger(log *logging.Logger) Option

func WithReadinessCheck

func WithReadinessCheck(name string, fn func() error) Option

WithReadinessCheck registers a named dependency check evaluated on /readyz. fn should return a non-nil error when the dependency is unhealthy.

func WithRegistrar

func WithRegistrar(r router.Registrar) Option

type Server

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

func NewServer

func NewServer(log *logging.Logger, cfg config.Config, opts ...Option) *Server

func (*Server) AddRoute

func (s *Server) AddRoute(port int, pattern string, h http.Handler)

AddRoute registers a handler on the given port and URL pattern. Must be called before Run.

func (*Server) Cfg

func (s *Server) Cfg() config.Config

Cfg returns a consistent snapshot of the server's current configuration.

func (*Server) Metrics added in v0.9.8

func (s *Server) Metrics() *metrics.Metrics

Metrics returns the server's metrics store so an embedder can register custom Collectors whose series render on the built-in /metrics endpoint alongside keel's own, through the same responder. Register before Run.

func (*Server) RegisterListener added in v0.9.10

func (s *Server) RegisterListener(name string) (onBound func())

RegisterListener enrolls an embedder-owned listener in the /readyz barrier. The caller binds and serves its own socket and must call the returned onBound once it is bound; until then /readyz is not-ready and lists "listener:<name>". Must be called before Run.

func (*Server) Reload

func (s *Server) Reload() error

Reload re-reads the configuration from the paths supplied via WithConfigPaths, validates it, and—if valid—applies live fields (stored config, TLS certificate). On any error the running configuration is left unchanged.

func (*Server) ReloadHandler

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

ReloadHandler returns an http.Handler for POST /admin/reload. A successful reload responds 200; an invalid config responds 422.

func (*Server) Run

func (s *Server) Run(ctx context.Context)

Directories

Path Synopsis
Package fips provides runtime FIPS posture verification.
Package fips provides runtime FIPS posture verification.
Package logging provides the structured logger used throughout keel.
Package logging provides the structured logger used throughout keel.
pkg/core/ports/ports.go
pkg/core/ports/ports.go
pkg/core/probes/mux.go
pkg/core/probes/mux.go
pkg/core/router/router.go
pkg/core/router/router.go
Package tracing implements a lightweight OTLP/HTTP span exporter using only the standard library.
Package tracing implements a lightweight OTLP/HTTP span exporter using only the standard library.

Jump to

Keyboard shortcuts

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