panichandler

package
v0.41.0 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2024 License: MPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package panichandler provides a panic handling errgroup.

Index

Constants

This section is empty.

Variables

View Source
var ErrPanic = errors.New(goroutinePanicked)

ErrPanic is the error returned when a task panics.

Functions

func Go

func Go(f func(), logger *zap.Logger)

Go runs the given function in a goroutine, handling panics by logging them.

This function is a panic-handling wrapper for the "go" keyword.

Types

type ErrGroup

type ErrGroup struct {
	// contains filtered or unexported fields
}

ErrGroup wraps golang.org/x/sync/errgroup.Group to handle panics by turning them into errors. It MUST be created using NewErrGroup.

func ErrGroupWithContext

func ErrGroupWithContext(ctx context.Context) (*ErrGroup, context.Context)

ErrGroupWithContext creates a new ErrGroup with the given context.

func NewErrGroup

func NewErrGroup() *ErrGroup

NewErrGroup creates a new ErrGroup.

func (*ErrGroup) Go

func (eg *ErrGroup) Go(f func() error)

Go runs the given function in a goroutine, handling panics by turning them into errors.

func (*ErrGroup) SetLimit

func (eg *ErrGroup) SetLimit(n int)

SetLimit sets the maximum number of goroutines that can run concurrently.

func (*ErrGroup) Wait

func (eg *ErrGroup) Wait() error

Wait waits for all goroutines to finish and returns the first error that occurred.

Jump to

Keyboard shortcuts

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