Expand description
Server accept loop, background tasks, and graceful shutdown.
Contains the runtime infrastructure that sits between the TCP listener
and the per-request proxy pipeline. This module is intentionally
decoupled from main() so that the server logic remains testable
and reusable without pulling in process-level concerns like signal
handling or std::process::exit.
Structs§
- Server
State - Runtime state shared across the accept loop.
Functions§
- serve
- Accepts connections on
listener, optionally wrapping each in TLS, and dispatches them through the proxy pipeline using the givenclientand sharedstate. Generic over the client connector type so that both plain-HTTP and HTTPS upstreams use the same accept loop. - shutdown_
signal - Awaits a shutdown signal (SIGINT or SIGTERM on Unix, Ctrl+C on all platforms). Returns once the first signal is received.
- spawn_
health_ checker - Spawns a background task that periodically probes each upstream backend at the configured health check path, updating health state based on HTTP response status.
- spawn_
rate_ limit_ cleanup - Spawns a background task that periodically prunes stale entries from the rate limiter, preventing unbounded memory growth.