Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServer ¶
HTTPServer is an abstraction of something that listens for connections and do HTTP things. 99% of the time, you'll pass in a net/http/Server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server wraps around a HTTPServer and will gracefully shutdown when it receives a shutdown signal.
func NewServer ¶
func NewServer(server HTTPServer, options ...ServerOption) *Server
NewServer returns a Server that can gracefully shutdown on shutdown signals.
func (*Server) ListenAndServe ¶
ListenAndServe will call the ListenAndServe function of the delegate HTTPServer you passed in at construction. On a signal being sent to the shutdown signal provided in the constructor, it will call the server's Shutdown method to attempt to gracefully shutdown.
type ServerOption ¶ added in v0.2.0
type ServerOption func(server *Server)
ServerOption provides ways of configuring Server.
func WithShutdownSignal ¶ added in v0.2.0
func WithShutdownSignal(shutdownSignal <-chan os.Signal) ServerOption
WithShutdownSignal WithShutdownSignals allows you to listen to whatever signals you like, rather than the default ones defined in signal.go.
func WithTimeout ¶ added in v0.2.0
func WithTimeout(timeout time.Duration) ServerOption
WithTimeout lets you set your own timeout for waiting for graceful shutdown. By default this is set to 30 seconds (k8s' default TerminationGracePeriod).