go.bigb.es/auxilia
Documentation
Index
Types
type Service struct { // Addr is the listen address (e.g. ":8080" or "127.0.0.1:0"). Required. Addr string // Handler is the root http.Handler. Required. Handler http.Handler // ReadTimeout, WriteTimeout, and IdleTimeout map onto the matching // http.Server fields. Zero values fall through to net/http defaults. ReadTimeout time.Duration WriteTimeout time.Duration IdleTimeout time.Duration // ShutdownTimeout caps Stop's drain window. Zero means 30 seconds. ShutdownTimeout time.Duration // Logger is optional. When nil, slog.Default() is used. Logger *slog.Logger // BaseContext is optional; it is passed through to // http.Server.BaseContext. The default is the standard library default. BaseContext func(net.Listener) context.Context // contains filtered or unexported fields }
Service is a steward-managed HTTP server.
Configure the public fields before adding the service to the steward Manager. Leave private fields zero. Init builds the underlying *http.Server; Start runs the listener in a goroutine; Stop drains via Shutdown with ShutdownTimeout.
func (s *Service) HealthCheck(_ context.Context) error
HealthCheck returns nil while the listener is running, or the wrapped listener error after the goroutine exits unexpectedly.
func (s *Service) Init(_ context.Context) error
Init validates the configuration and constructs the underlying *http.Server. It is safe to inspect Addr and Handler after Init returns.
Addr returns the actual listen address. Most useful when configured with a wildcard port like "127.0.0.1:0" — the OS-assigned port is only known after Start.
func (s *Service) Start(_ context.Context) error
Start binds the listener (so bind errors surface synchronously) and runs Serve in a goroutine. Returns once the listener is bound.
func (s *Service) Stop(ctx context.Context) error
Stop drains in-flight requests via http.Server.Shutdown, capped by ShutdownTimeout (default 30s). Idempotent: a second call is a no-op.
Package httpsvc exposes an HTTP server as a steward-managed service.
Init builds the underlying *http.Server, Start binds the listener and runs Serve in a goroutine, Stop drains via Shutdown with a configurable timeout. A listener failure observed after Start is reported via the steward HealthChecker interface.