jonmorehouse / gatekeeper

a pluggable http routing runtime
12 stars 1 forks source link

graceful connection package #5

Closed jonmorehouse closed 8 years ago

jonmorehouse commented 8 years ago

Let's create a package "gatekeeper/graceful" which implements "graceful" connection handling similar to the https://github.com/tylerb/graceful package or facebook's https://github.com/facebookgo/httpdown package.

Specifically, I think we should handle three types of servers:

It seems to me like the best way to do this would be to create a small "shim" type around net.TCPListener similarly to the net/http.tcpKeepAlive type here

We can then expose a "graceful" loop there which sets deadlines on the listener and accepts a "stop" channel to signal the underlying loop to stop accepting new connections. Said method can then wait a "grace" period before closing all of the other tcp connections and closing the connection alltogether.

Seems like something that can definitely wait until we're further along.