Documentation
¶
Overview ¶
Package svcboot starts every service the same way: server, request IDs, metrics and tracing.
Run(Config) builds the http.Server with safe timeouts, wraps the handler with request IDs, request metrics and tracing, and serves until shutdown. APIKeySet and APIKeysFromEnv parse comma-separated API key lists. Services call it from main so they all start, log and shut down the same way.
Index ¶
- Constants
- func APIKeySet(envValue string) map[string]struct{}
- func APIKeysFromEnv(name string) map[string]struct{}
- func NewHTTPServer(addr string, handler http.Handler) *http.Server
- func Run(cfg Config) error
- func WithRequestID(next http.Handler) http.Handler
- func WrapHandler(serviceName string, requestMetrics *telemetry.RequestMetrics, ...) http.Handler
- type Config
Constants ¶
const ( DefaultReadHeaderTimeout = 5 * time.Second DefaultReadTimeout = 15 * time.Second DefaultWriteTimeout = 15 * time.Second DefaultIdleTimeout = 60 * time.Second )
Default per-connection timeouts for split API services. Routes that accept large uploads or run long operations (for example the runtime-api registry push) extend their own deadlines with http.ResponseController instead of raising these for every route.
Variables ¶
This section is empty.
Functions ¶
func APIKeysFromEnv ¶
APIKeysFromEnv reads a comma-separated API key list from the named variable.
func NewHTTPServer ¶
NewHTTPServer returns the service HTTP server with the shared default timeouts.
func WithRequestID ¶
WithRequestID gives every request an identifier and returns it in the X-Request-Id response header. A well-formed identifier from the caller is kept so a trace can span services; anything else is replaced, never echoed, so the header cannot carry injected data. The same identifier is stored on the request context, which is where audit writes and access logs read it.
func WrapHandler ¶
func WrapHandler(serviceName string, requestMetrics *telemetry.RequestMetrics, next http.Handler) http.Handler
WrapHandler applies the shared OTEL, request logging, and request metrics middleware. The wrapped writers unwrap to the connection's writer, so handlers can still use http.ResponseController to extend deadlines.