servenv

package
v0.0.0-...-3712671 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const JQueryIncludes = `` /* 287-byte string literal not displayed */

JQueryIncludes is the include to use to be able to use jquery and jquery-ui

Variables

View Source
var (
	// The flags used when calling RegisterDefaultSecureFlags.
	SecurePort *int
	CertFile   *string
	KeyFile    *string
	CACertFile *string
)
View Source
var (
	// The flags used when calling RegisterDefaultFlags.
	Port *int

	// filled in when calling Run
	ListeningURL url.URL
)
View Source
var (
	// The flags used when calling RegisterDefaultSocketFileFlags.
	SocketFile *string
)

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 RegisterDefaultFlags

func RegisterDefaultFlags()

RegisterDefaultFlags registers the default flags for listening to a given port for standard connections. If calling this, then call RunDefault()

func RegisterDefaultSecureFlags

func RegisterDefaultSecureFlags()

RegisterDefaultSecureFlags registers the default flags for listening to a different port for secure connections. It also registers an OnRun callback to enable the listening socket. This needs to be called before flags are parsed.

func RegisterDefaultSocketFileFlags

func RegisterDefaultSocketFileFlags()

RegisterDefaultSocketFileFlags registers the default flags for listening to a socket. It also registers an OnRun callback to enable the listening socket. This needs to be called before flags are parsed.

func Run

func Run(port int)

Run starts listening for RPC and HTTP requests, and blocks until it the process gets a signal.

func RunDefault

func RunDefault()

RunDefault calls Run() with the parameters from the flags.

func ServeRPC

func ServeRPC()

func ServeSecurePort

func ServeSecurePort(securePort int, certFile, keyFile, caCertFile string)

ServerSecurePort obtains a listener that accepts secure connections. If the provided port is zero, the listening is disabled.

func ServeSocketFile

func ServeSocketFile(name string)

ServeSocketFile listen to the named socket and serves RPCs on it.

func StatusURLPath

func StatusURLPath() string

StatusURLPath returns the path to the status page.

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