pub async fn serve_tls<S>(
listener: TcpListener,
router: Router,
server: &Server,
shutdown: S,
) -> Result<()>tls only.Expand description
Serves router over TLS until shutdown completes.
The TLS material and the audit sink both come from server, which is the
same one the router was built over; router is passed separately so that
an embedder can wrap it — a layer of its own, a different fallback — the
way it can with axum::serve().
Shutdown is graceful in both halves: the listener stops accepting, and every connection already open is told to finish the request it is serving and close. A config server is restarted by a rollout, and dropping the fetch a pod is making at that moment would make a rollout look like a configuration failure to whoever is starting up beside it.
Graceful, and bounded: a connection that has not finished within
DRAIN_TIMEOUT is dropped. An open change stream has no end of its
own, so an unbounded drain would be a rollout that waits for its
subscribers rather than the other way round.
§Errors
Only what the listener itself reports. A connection that fails — a handshake that was refused, a client that went away — ends that connection and nothing else.
§Panics
If server is not configured for TLS. Callers reach this function
through Server::tls, which is None exactly when that is so.