cliutil

package
v0.0.0-...-300ac43 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AttachAppContext

func AttachAppContext(ctx context.Context, app *cli.App)

func CommandContext

func CommandContext(c *cli.Context) context.Context

func JoinBefore

func JoinBefore(fns ...cli.BeforeFunc) cli.BeforeFunc

func NewInterruptHandler

func NewInterruptHandler(cancel context.CancelFunc, sigs ...os.Signal) io.Closer

NewInterruptHandler returns a new interrupt handler that will invoke cancel if any of the signals provided are received.

Types

type InterruptHandler

type InterruptHandler struct {
	// contains filtered or unexported fields
}

InterruptHandler helps set up an interrupt handler that can be cleanly shut down through the io.Closer interface.

func (*InterruptHandler) Close

func (ih *InterruptHandler) Close() error

Close closes its signal receiver and waits for its handlers to exit cleanly.

func (*InterruptHandler) Handle

func (ih *InterruptHandler) Handle(handler handlerFunc, sigs ...os.Signal)

Handle starts handling the given signals, and will call the handler callback function each time a signal is catched. The function is passed the number of times the handler has been triggered in total, as well as the handler itself, so that the handling logic can use the handler's wait group to ensure clean shutdown when Close() is called.

Jump to

Keyboard shortcuts

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