programatik29 / axum-server

High level server designed to be used with axum framework.
MIT License
168 stars 56 forks source link

feat: inform connections on a graceful shutdown request #67

Closed neoeinstein closed 1 year ago

neoeinstein commented 1 year ago

Currently, on a graceful shutdown, connections are not informed, however for streaming or long-lived connections, it can be valuable to inform the connections that we wish them to shut down. Currently, with an open HTTP/2 channel, the graceful shutdown mechanism does not cause the server to begin winding down the connection, instead waiting until the graceful termination timeout elapses before killing the whole server.

With this change, on a graceful shutdown signal, the connection will be notified, and then it will return to waiting for either the connection to self-terminate or the termination timeout. On HTTP/2, this allows it to send the appropriate GOAWAY frame when the connection has processed all pending requests.

This also has the benefit of terminating keep-alive probes for HTTP/1.1 enabling faster graceful shutdown for those connections as well.