Documentation
¶
Overview ¶
Package errgroup provides synchronization, error propagation, and Context cancellation for groups of goroutines working on subtasks of a common task.
It wraps, and exposes a similar API to, the upstream package golang.org/x/sync/errgroup. Our version additionally recovers from panics, converting them into errors.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func CollectStack ¶
func CollectStack() []byte
func FromPanicValue ¶
func FromPanicValue(i interface{}) error
FromPanicValue takes a value recovered from a panic and converts it into an error, for logging purposes. If the value is nil, it returns nil instead of an error.
Use like:
defer func() { err := FromPanicValue(recover()) // log or otheriwse use err }()
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
A Group is a collection of goroutines working on subtasks that are part of the same overall task.
A zero Group is valid and does not cancel on error.
func WithContext ¶
WithContext returns a new Group and an associated Context derived from ctx.
The derived Context is canceled the first time a function passed to Go returns a non-nil error or panics, or the first time Wait returns, whichever occurs first.