Back to / internal / servicegroup

Package servicegroup

Latest Go to latest
Published: Oct 18, 2019 | License: MIT | Module:


Package Files

type Group

type Group struct {
	// contains filtered or unexported fields

A Group is a set of subtasks that occur as part of a parent task which runs until an error occurs or its context is canceled.

func NewGroup

func NewGroup(ctx context.Context) *Group

NewGroup returns a Group that is bound to ctx. No new tasks can be started once the group's context has been canceled.

func (*Group) Go

func (g *Group) Go(
	fn func(context.Context) error,
) error

Go calls the given function in a new goroutine.

It returns a non-nil error if the group's context has been canceled, or another task has returned a non-nil error.

The context passed to fn is canceled when the group's context is canceled, or some other task returns a non-nil error.

func (*Group) Wait

func (g *Group) Wait() error

Wait blocks until an error occurs or the group's context is canceled.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to identifier