modules

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: May 22, 2019 License: GPL-3.0 Imports: 7 Imported by: 17

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (

	// ErrCleanExit is returned by Start() when the program is interrupted before starting. This can happen for example, when using the "--help" flag.
	ErrCleanExit = errors.New("clean exit requested")
)

Functions

func Shutdown

func Shutdown() error

Shutdown stops all modules in the correct order.

func ShuttingDown

func ShuttingDown() <-chan struct{}

ShuttingDown returns a channel read on the global shutdown signal.

func Start

func Start() error

Start starts all modules in the correct order. In case of an error, it will automatically shutdown again.

func StartCompleted

func StartCompleted() bool

StartCompleted returns whether starting has completed.

func WaitForStartCompletion

func WaitForStartCompletion() <-chan struct{}

WaitForStartCompletion returns as soon as starting has completed.

Types

type Module

type Module struct {
	Name    string
	Prepped *abool.AtomicBool
	Started *abool.AtomicBool
	Stopped *abool.AtomicBool
	// contains filtered or unexported fields
}

Module represents a module.

func Register

func Register(name string, prep, start, stop func() error, dependencies ...string) *Module

Register registers a new module.

func (*Module) ReadyToPrep

func (m *Module) ReadyToPrep() bool

ReadyToPrep returns whether all dependencies are ready for this module to prep.

func (*Module) ReadyToStart

func (m *Module) ReadyToStart() bool

ReadyToStart returns whether all dependencies are ready for this module to start.

func (*Module) ReadyToStop

func (m *Module) ReadyToStop() bool

ReadyToStop returns whether all dependencies are ready for this module to stop.

Jump to

Keyboard shortcuts

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