Documentation
¶
Overview ¶
Package server wires the hub, auth, limits and metrics packages into an http.Handler serving the two upgrade endpoints (/v1/agent, /v1/client) and /healthz. It is the only package that speaks WebSocket protocol directly — reading hellos, running the forwarding pump, broadcasting going_away on shutdown.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Handler ¶
Handler returns the mux serving /v1/agent, /v1/client, /healthz and /stats — exposed separately from Run so tests can drive it via httptest.Server without binding a real port.
func (*Server) Run ¶
Run listens on cfg.Addr and blocks until ctx is cancelled, then performs a graceful shutdown bounded by cfg.ShutdownGrace.
func (*Server) Serve ¶
Serve runs the server on an already-open listener — split out from Run so tests can use a listener bound to an ephemeral port.
func (*Server) Shutdown ¶
Shutdown announces going_away to every currently-open connection, waits (bounded by ctx) for their pumps to drain, then stops the HTTP listener.
This exists because net/http.Server.Shutdown explicitly does NOT wait for hijacked connections — and a WebSocket upgrade hijacks the underlying TCP connection — so without this, every open session would hang until its own ping-timeout on every deploy instead of getting a clean, fast reconnect signal (spec §8: close code 1001, retry with no backoff escalation).