picker

package
v1.18.8 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2024 License: GPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Picker

type Picker[T any] struct {
	// contains filtered or unexported fields
}

Picker provides synchronization, and Context cancelation for groups of goroutines working on subtasks of a common task. Inspired by errGroup

func WithContext

func WithContext[T any](ctx context.Context) (*Picker[T], context.Context)

WithContext returns a new Picker and an associated Context derived from ctx. and cancel when first element return.

func WithTimeout

func WithTimeout[T any](ctx context.Context, timeout time.Duration) (*Picker[T], context.Context)

WithTimeout returns a new Picker and an associated Context derived from ctx with timeout.

func (*Picker[T]) Close

func (p *Picker[T]) Close() error

Close cancels the picker context and releases resources associated with it. If Wait has been called, then there is no need to call Close.

func (*Picker[T]) Error

func (p *Picker[T]) Error() error

Error return the first error (if all success return nil)

func (*Picker[T]) Go

func (p *Picker[T]) Go(f func() (T, error))

Go calls the given function in a new goroutine. The first call to return a nil error cancels the group; its result will be returned by Wait.

func (*Picker[T]) Wait

func (p *Picker[T]) Wait() T

Wait blocks until all function calls from the Go method have returned, then returns the first nil error result (if any) from them.

Jump to

Keyboard shortcuts

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