graceful

package module
v0.0.0-...-4b32062 Latest Latest
Warning

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

Go to latest
Published: Jul 19, 2017 License: Apache-2.0 Imports: 5 Imported by: 1

README

tick-graceful

graceful

Documentation

Overview

Package gracehttp provides easy to use graceful restart functionality for HTTP server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(addr string, timeout time.Duration, n http.Handler, logFunc LogFunc)

Run serves the http.Handler with graceful shutdown enabled.

timeout is the duration to wait until killing active requests and stopping the server. If timeout is 0, the server never times out. It waits for all active requests to finish.

Types

type BeforeShutdownFunc

type BeforeShutdownFunc func() bool

type ConnStateFunc

type ConnStateFunc func(net.Conn, http.ConnState)

type Graceful

type Graceful struct {
	Server    *libGraceful.Server
	Interrupt chan os.Signal
}

func (*Graceful) ListenAndServe

func (g *Graceful) ListenAndServe() error

func (*Graceful) ListenAndServeTLS

func (g *Graceful) ListenAndServeTLS(certFile, keyFile string) error

func (*Graceful) Serve

func (g *Graceful) Serve(listener net.Listener) error

type GracefulBuilder

type GracefulBuilder interface {
	Server(server *http.Server) GracefulBuilder
	Timeout(timeout time.Duration) GracefulBuilder
	LogFunc(logFunc LogFunc) GracefulBuilder
	ConnState(connStateFunc ConnStateFunc) GracefulBuilder
	BeforeShutdown(beforeShutdownFunc BeforeShutdownFunc) GracefulBuilder
	ShutdownInitiated(shutdownInitiatedFunc ShutdownInitiatedFunc) GracefulBuilder
	Interrupt(interrupt chan os.Signal) GracefulBuilder
	Build() *Graceful
}

func New

func New() GracefulBuilder

type LogFunc

type LogFunc func(format string, args ...interface{})

type ShutdownInitiatedFunc

type ShutdownInitiatedFunc func()

Jump to

Keyboard shortcuts

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