Documentation ¶
Overview ¶
Package errgroup is bit more advanced than golang.org/x/sync/errgroup. Major difference is that when error group is created with WithContext the parent context would implicitly cancel all functions called by Go method.
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
}
The Group is superior errgroup.Group which aborts whole group execution when parent context is cancelled
func WithContext ¶
WithContext creates Group and store inside parent context so the Go method would respect parent context cancellation
func (*Group) Go ¶
Go runs the provided f function in a dedicated goroutine and waits for its completion or for the parent context cancellation.
func (*Group) SetLimit ¶
SetLimit limits the number of active goroutines in this group to at most n. A negative value indicates no limit.
Any subsequent call to the Go method will block until it can add an active goroutine without exceeding the configured limit.
The limit must not be modified while any goroutines in the group are active.
func (*Group) TryGo ¶
TryGo calls the given function in a new goroutine only if the number of active goroutines in the group is currently below the configured limit.
The return value reports whether the goroutine was started.