Documentation ¶
Overview ¶
Package lifecycle implements a simple helper object to make synchronization of worker goroutines a little less verbose.
Index ¶
- type Lifecycle
- func (this *Lifecycle) QueryHeartbeat() <-chan bool
- func (this *Lifecycle) QueryRun() bool
- func (this *Lifecycle) QueryShutdown() <-chan bool
- func (this *Lifecycle) Shutdown()
- func (this *Lifecycle) ShutdownComplete()
- func (this *Lifecycle) StartHeart(heartbeatMs int)
- func (this *Lifecycle) StopHeart()
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Lifecycle ¶
type Lifecycle struct {
// contains filtered or unexported fields
}
Lifecycle provides a simple way to coordinate the lifecycle of worker goroutines that loop infinitely
func New ¶
func New() *Lifecycle
New is a helper function which creates a newly initialized Lifecycle object and returns a pointer to it for use.
func (*Lifecycle) QueryHeartbeat ¶
QueryHeartbeat returns the read-only channel on which a user should listen for a periodic heartbeat signal.
func (*Lifecycle) QueryRun ¶
QueryRun returns the current status of the Sync object. It will return true until Shutdown() is called. Client code can use this function as their criteria in a typical for-select work loop.
func (*Lifecycle) QueryShutdown ¶
QueryShutdown returns the read-only channel on which a user should listen for a signal to shut down.
func (*Lifecycle) Shutdown ¶
func (this *Lifecycle) Shutdown()
Shutdown sets the run flag to false, sends the shutdown signal back to the client on the shutdown channel, and then blocks until the client calls ShutdownComplete()
func (*Lifecycle) ShutdownComplete ¶
func (this *Lifecycle) ShutdownComplete()
ShutdownComplete sends a signal which unblocks the call to Shutdown(). Client code should call this function once its shutdown procedures are completed.
func (*Lifecycle) StartHeart ¶
StartHeart sets the heartbeat cycle time in milliseconds and starts the heartbeat timer.