Documentation
¶
Overview ¶
Package supervisor implements a common pattern for network programs: multiple goroutines are listening at network sockets, and the first error should be transmitted to all the other routines.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Supervisor ¶
type Supervisor struct {
// contains filtered or unexported fields
}
Supervisor is the top-level group
func WithContext ¶
func WithContext(ctx context.Context) (*Supervisor, context.Context)
WithContext returns a new Group and an associated Context derived from ctx.
The derived Context is canceled the first time an agent returns a non-nil error, or when all agents are successfully completed.
func (*Supervisor) Agent ¶
func (s *Supervisor) Agent(f func() error)
Agent adds a new routine to the group.
func (*Supervisor) Err ¶
func (s *Supervisor) Err() <-chan error
Err returns a channel that will deliver a single value on the first error in the group, or nil if no error occurred, but there are no routines left in the group.