errgroup

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2024 License: MIT Imports: 4 Imported by: 2

README

errgroup

Provides a panic handling wrapper around golang.org/x/sync/errgroup to avoid application crashes when a goroutine encounters a panic. In the event of a panic this wrapper will convert the panic into an error that is returned from the Wait function. In all other ways this wrapper behaves exactly as the wrapped Group.

Documentation

Overview

Package errgroup provides a panic handling wrapper around golang.org/x/sync/errgroup to avoid application crashes when a goroutine encounters a panic.

In the event of a panic this wrapper will convert the panic into an error that is returned from the Wait function. In all other ways this wrapper behaves exactly as the wrapped Group.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Group

type Group interface {
	Go(f func() error)
	Wait() error
}

Group provides an interface compatible with golang.org/x/sync/errgroup for instances that enhance the capabilities of Groups.

func New

func New(opts ...Opt) Group

New creates a panic-handling Group, without any context cancellation.

func NewContext added in v0.3.0

func NewContext(ctx context.Context, opts ...Opt) (Group, context.Context)

NewContext creates a panic-handling Group. The returned context is cancelled on first error, first panic, or when the Wait function exits.

type Opt added in v0.2.11

type Opt func(g *panicGroup)

Opt is a configuration option.

func WithPanicHandler added in v0.2.11

func WithPanicHandler(ph PanicHandler) Opt

WithPanicHandler overrides the default panic handler.

type PanicHandler added in v0.2.9

type PanicHandler func(p any) error

PanicHandler processes the recovered panic.

Jump to

Keyboard shortcuts

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