graceful

package module
v0.0.0-...-c35c025 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 26, 2015 License: MIT Imports: 4 Imported by: 3

README

This package can now be found at https://github.com/icub3d/gop/graceful.

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 Close

func Close() error

Close gracefully shuts down the DefaultServer.

func ListenAndServe

func ListenAndServe(addr string, handler http.Handler) error

ListenAndServe listens on the TCP network address addr using the DefaultServer. If the handler is nil, http.DefaultServeMux is used.

func ListenAndServeTLS

func ListenAndServeTLS(addr, certFile, keyFile string, handler http.Handler) error

ListenAndServeTLS acts identically to ListenAndServe except that is expects HTTPS connections using the given certificate and key.

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 NewServer

func NewServer(srv *http.Server) *Server

NewServer turns the given net/http server into a graceful server.

func (*Server) Close

func (s *Server) Close() error

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

func (s *Server) ListenAndServe() error

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

func (s *Server) ListenAndServeTLS(certFile, keyFile string) error

ListenAndServeTLS works like ListenAndServe but with TLS using the given cert and key files.

func (*Server) Serve

func (s *Server) Serve(l net.Listener) error

Serve works like ListenAndServer but using the given listener.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL