Documentation
¶
Index ¶
- Constants
- type Manager
- func (l *Manager) AbnormalShutdown()
- func (l *Manager) AwaitShutdownComplete()
- func (l *Manager) BeginInitialization() bool
- func (l *Manager) BeginShutdown() bool
- func (l *Manager) InitializationComplete() bool
- func (l *Manager) IsRunning() bool
- func (l *Manager) Setup()
- func (l *Manager) ShutdownComplete()
- func (l *Manager) ShutdownRequested() <-chan struct{}
- func (l *Manager) Status() int32
- type Status
Constants ¶
const ( StatusIdle = iota StatusStarting StatusInitializationCancelled StatusRunning StatusStopping )
Status constants
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
Manager is a trait to be embedded in structs that manage the lifecycle of goroutines. The trait enables the struct to easily switch between states and await proper shutdown
func (*Manager) AbnormalShutdown ¶
func (l *Manager) AbnormalShutdown()
AbnormalShutdown should be called when the goroutine exits without Stop being called.
func (*Manager) AwaitShutdownComplete ¶
func (l *Manager) AwaitShutdownComplete()
AwaitShutdownComplete can be called in case you need to join against the goroutine's end
func (*Manager) BeginInitialization ¶
BeginInitialization should be called in the .Start() method (or whichever begins the async work)
func (*Manager) BeginShutdown ¶
BeginShutdown should be called on the .Stop() method or whichever makes a request for the async work to stop
func (*Manager) InitializationComplete ¶
InitializationComplete should be called just prior to the `go ...` directive starting the async work
func (*Manager) ShutdownComplete ¶
func (l *Manager) ShutdownComplete()
ShutdownComplete should be called just before the goroutine exits. (ie: it should be the FIRST deferred func)
func (*Manager) ShutdownRequested ¶
func (l *Manager) ShutdownRequested() <-chan struct{}
ShutdownRequested should be queried in a select statement, which should react by terminating the goroutine