Documentation ¶
Overview ¶
Package cmd contains the Context type that can be used to cleanly terminate an application upon receiving a Termination signal. This package wrapps the basic pattern I have observed to enable it to be simpler to use.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Cancelled ¶
func Cancelled() <-chan struct{}
Cancelled is provided for use in select statments. It can be used to determine if a termination signal has been sent.
func Complete ¶
func Complete(fns ...func())
Complete is a blocking call that should be the last call in your main function. The purpose of this function is to wait for the cancel go routine to cleanup corretly.
func IsCancelled ¶
func IsCancelled() bool
IsCancelled is provided for use in if and for blocks, this can be used to check to see if a termination signal has been send, and to the excuate appropriate logic as needed.
func New ¶
New initilizes and setups up the global context. An explicate list of signals can be passed in as well, if no list is passed os.Interrupt, and syscall.SIGTERM is assumed.
func NewContext ¶
NewContext initilizes and setups up the context. An explicate list of signals can be passed in as well, if no list is passed os.Interrupt, and syscall.SIGTERM is assumed.
func OnComplete ¶
func OnComplete(fns ...func())
OnComplete adds a set of functions that are called just before complete; exists. The functions are called in reverse order. function passed to Complete are called after functions defined by OnComplete
Types ¶
This section is empty.