Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
A Group synchronizes the startup and shutdown behaviour of multiple routines.
All registered routines start running simultaneously. If any routine stops, all other routines in the group are gracefully shut down.
Similarly, a call to Stop will gracefully shut down all routines in the group.
A group is thread-safe in the sense that it can run multiple routines and track their statuses without data races.
func (*Group) Start ¶
Start starts all routines in the group.
This function blocks until all routines in the group have finished running.
If one or more routines stop early and produce an error, this function returns with the first error that was captured.
This function also captures any SIGINT, SIGQUIT or SIGTERM signals received from the host environment. After receiving any of these signals, all routines in the group are shut down gracefully.
type Routine ¶
type Routine interface {
// Start starts the routine and blocks until it completes.
// This function will return an error if the routine stops unexpectedly.
Start() error
// Stop stops the running routine.
// Calling this function will cause Start to return without an error.
Stop()
}
A Routine is a long-running task that can be started and stopped.
