Documentation
¶
Overview ¶
Package graceful provides a net/http compatible Server that can be gracefully shut down. When closed, the server stops accepting new connections. It then waits for open connections to finish before returning.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ListenAndServe ¶
ListenAndServe listens on the TCP network address addr using the DefaultServer. If the handler is nil, http.DefaultServeMux is used.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is net/http compatible graceful server.
var DefaultServer *Server
DefaultServer is the default Server used by the functions in this package. It's used as to simplify using the graceful server.
func (*Server) Close ¶
Close gracefully shuts down the listener. This should be called when the server should stop listening for new connection and finish any open connections.
func (*Server) ListenAndServe ¶
ListenAndServe works like net/http.Server.ListenAndServe except that it gracefully shuts down when Close() is called. When that occurs, no new connections will be allowed and existing connections will be allowed to finish. This will not return until all existing connections have closed.
func (*Server) ListenAndServeTLS ¶
ListenAndServeTLS works like ListenAndServe but with TLS using the given cert and key files.