servenv

package
v2.0.0-beta.2+incompat... Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2016 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 (
	// GRPCPort is the port to listen on for gRPC. If not set or zero, don't listen.
	GRPCPort *int

	// GRPCCert is the cert to use if TLS is enabled
	GRPCCert *string

	// GRPCKey is the key to use if TLS is enabled
	GRPCKey *string

	// GRPCCA is the CA to use if TLS is enabled
	GRPCCA *string

	// GRPCServer is the global server to serve gRPC.
	GRPCServer *grpc.Server
)

This file handles gRPC server, on its own port. Clients register servers, based on service map:

servenv.RegisterGRPCFlags()

servenv.OnRun(func() {
  if servenv.GRPCCheckServiceMap("XXX") {
    pb.RegisterXXX(servenv.GRPCServer, XXX)
  }
}

Note servenv.GRPCServer can only be used in servenv.OnRun, and not before, as it is initialized right before calling OnRun.

View Source
var (
	// The flags used when calling RegisterDefaultFlags.
	Port *int

	// filled in when calling Run
	ListeningURL url.URL
)
View Source
var (
	// SocketFile has the flag 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 CheckServiceMap

func CheckServiceMap(protocol, name string) bool

CheckServiceMap returns if we should register a RPC service (and also logs how to enable / disable it)

func Close

func Close()

Close runs any registered exit hooks in parallel.

func GRPCCheckServiceMap

func GRPCCheckServiceMap(name string) bool

GRPCCheckServiceMap returns if we should register a gRPC service (and also logs how to enable / disable it)

func HandlePanic

func HandlePanic(component string, err *error)

HandlePanic should be called using 'defer' in the RPC code that executes the command.

func Init

func Init()

func InitServiceMap

func InitServiceMap(protocol, name string)

InitServiceMap will set the default value for a protocol/name to be served.

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 a function to be run when the process receives a SIGTERM. This allows the program to change its behavior during the lameduck period.

All hooks are run in parallel, and there is no guarantee that the process will wait for them to finish before dying when the lameduck period expires.

See also: OnTermSync

func OnTermSync

func OnTermSync(f func())

OnTermSync registers a function to be run when the process receives SIGTERM. This allows the program to change its behavior during the lameduck period.

All hooks are run in parallel, and the process will do its best to wait (up to -onterm_timeout) for all of them to finish before dying.

See also: OnTerm

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 RegisterDefaultSocketFileFlags

func RegisterDefaultSocketFileFlags()

RegisterDefaultSocketFileFlags registers the default flags for listening to a socket. This needs to be called before flags are parsed.

func RegisterGRPCFlags

func RegisterGRPCFlags()

RegisterGRPCFlags registers the right command line flag to enable gRPC

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 StatusURLPath

func StatusURLPath() string

StatusURLPath returns the path to the status page.

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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