multierrgroup

package module
v1.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 26, 2023 License: MIT Imports: 3 Imported by: 2

README

Go Reference Go Report Card

Multierrgroup provides a marriage of x/sync/errgroup and hashicorp's multierror. Start up as many error-returning goroutines as you need and get a multierror with all the failures that occurred once they're all finished.

var meg multerrgroup.Group

meg.Go(func() error {
  // Do something dangerous
})

meg.Go(func() error {
  // Try something you know will probably never work
})

err := meg.Wait()

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 can perform many operations in parallel, returning all errors that occur, as a hashicorp/go-multierror.Error instance, once all operations have completed.

func WithContext

func WithContext(ctx context.Context) (*Group, context.Context)

func (*Group) Go

func (g *Group) Go(f func() error)

Go begins an operation in parallel.

func (*Group) GoWithContext added in v1.1.0

func (g *Group) GoWithContext(ctx context.Context, f func(context.Context) error)

GoWithContext is a helper for funcs or methods that already take a context, to avoid annoying boilerplate.

func (*Group) Wait

func (g *Group) Wait() error

Wait waits for all routines to return and returns the errors, if any.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL