errgroup

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: MIT Imports: 3 Imported by: 5

README

Go Reference Go Report Card

simplylib/errgroup

A Go (golang) library that is a drop in replacement for x/sync/multierror with one major change,

where x/sync/multierror's Group.Wait() "returns the first non-nil error (if any)"

simplylib/errgroup's Group.Wait() returns all the errors using simplylib/multierror

Documentation

Overview

Package errgroup implements a mostly drop in replacement for golang.org/x/sync/multierror with one major change, where golang.org/x/sync/errgroup returns the first non-nil error (if any) github.com/simplylib/errgroup returns all the errors using github.com/simplylib/multierror

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
}

Group of goroutines concurrently running tasks, optionally limited by SetLimit(int).

func WithContext added in v0.0.4

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

func (*Group) Go

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

Go run a function in a separate Goroutine, unbounded by default unless SetLimit(int) is called.

func (*Group) SetLimit

func (g *Group) SetLimit(n int)

SetLimit of concurrently running goroutines to n, must be called before.

func (*Group) TryGo added in v0.0.2

func (g *Group) TryGo(f func() error) bool

TryGo calls f in a separate goroutine, only if the goroutine limit set in SetLimit is not reached at moment of Calling TryGo. Acts like Group.Go if SetLimit was not run. Returns true if goroutine will/was started, false if not.

func (*Group) Wait

func (g *Group) Wait() error

Wait until all goroutines are finished and returning a Multierror if len(errors) > 1 or the direct error if 1.

Jump to

Keyboard shortcuts

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