lifecycle

package
v4.2.1-0...-85e7c47 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2021 License: Apache-2.0 Imports: 2 Imported by: 3

Documentation

Index

Constants

View Source
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

func (l *Manager) BeginInitialization() bool

BeginInitialization should be called in the .Start() method (or whichever begins the async work)

func (*Manager) BeginShutdown

func (l *Manager) BeginShutdown() bool

BeginShutdown should be called on the .Stop() method or whichever makes a request for the async work to stop

func (*Manager) InitializationComplete

func (l *Manager) InitializationComplete() bool

InitializationComplete should be called just prior to the `go ...` directive starting the async work

func (*Manager) IsRunning

func (l *Manager) IsRunning() bool

IsRunning returns true if the BG work is still going on

func (*Manager) Setup

func (l *Manager) Setup()

Setup must be called in the struct constructor

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

func (*Manager) Status

func (l *Manager) Status() int32

Status Returns the current status as an int32 constant

type Status

type Status = int32

Status type alias

Jump to

Keyboard shortcuts

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