servenv

package
v0.0.0-...-4754828 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2014 License: BSD-3-Clause Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Port           = flag.Int("port", 0, "port for the server")
	LameduckPeriod = flag.Duration("lameduck-period", 50*time.Millisecond, "how long to keep the server running on SIGTERM before stopping")
)
View Source
var (

	// filled in when calling Run or RunSecure
	ListeningURL url.URL
)
View Source
var (
	SecurePort = flag.Int("secure-port", 0, "port for the secure server")
)

Functions

func AddStatusFuncs

func AddStatusFuncs(fmap template.FuncMap)

AddStatusFuncs merges the provided functions into the set of functions used to render /debug/status. Call this before AddStatusPart if your template requires custom functions.

func AddStatusPart

func AddStatusPart(banner, frag string, f func() interface{})

AddStatusPart adds a new section to status. frag is used as a subtemplate of the template used to render /debug/status, and will be executed using the value of invoking f at the time of the /debug/status request. frag is parsed and executed with the html/template package. Functions registered with AddStatusFuncs may be used in the template.

func AddStatusSection

func AddStatusSection(banner string, f func() string)

AddStatusSection registers a function that generates extra information for /debug/status. If banner is not empty, it will be used as a header before the information. If more complex output than a simple string is required use AddStatusPart instead.

func Close

func Close()

Close runs any registered exit hooks in parallel.

func Init

func Init()

func NewThrottledListener

func NewThrottledListener(l net.Listener, maxRate int64, maxBuffer int) net.Listener

NewThrottledListener creates a ThrottledListener. maxRate specifies the maximum rate of accepts per second. If the backlog exceeds maxBuffer, the newly accepted connection is immediately closed.

func OnClose

func OnClose(f func())

OnClose registers f to be run at the end of the app lifecycle. This happens after the lameduck period just before the program exits. All hooks are run in parallel.

func OnRun

func OnRun(f func())

OnRun registers f to be run right at the beginning of Run. All hooks are run in parallel.

func OnTerm

func OnTerm(f func())

OnTerm registers f to be run when the process receives a SIGTERM. All hooks are run in parallel. This allows the program to change its behavior during the lameduck period.

func Run

func Run()

Run starts listening for RPC and HTTP requests, and blocks until it the process gets a signal. It may also listen on a secure port, or on a unix socket.

func ServeRPC

func ServeRPC()

Types

type ThrottledListener

type ThrottledListener struct {
	net.Listener
	// contains filtered or unexported fields
}

ThrottledListener throttles the number connections accepted to the specified rate.

func (*ThrottledListener) Accept

func (tln *ThrottledListener) Accept() (c net.Conn, err error)

Accept accepts a new connection, but ensures that the rate does not exceed the specified maxRate.

Jump to

Keyboard shortcuts

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