async

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllOf

func AllOf(ctx context.Context, jobs ...job) (errMsg string, err error)

AllOf runs all jobs concurrently and returns the first error encountered.

func AnyOf

func AnyOf[T any](ctx context.Context, fnList ...Fn[T]) (T, error)

AnyOf runs all jobs concurrently and returns the fastest job result that is not error.

func Submit

func Submit(ctx context.Context, jobs ...job)

Submit runs all jobs concurrently and returns when all jobs are done.

Types

type Builder

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

func NewBuilder

func NewBuilder() *Builder

func (*Builder) AddJob

func (p *Builder) AddJob(jobs ...job)

func (*Builder) Run

func (p *Builder) Run(ctx context.Context) (errMsg string, err error)

Run runs all jobs concurrently and returns the first error encountered.

func (*Builder) Submit

func (p *Builder) Submit(ctx context.Context)

Submit runs all jobs concurrently and returns when all jobs are done.

type Fn

type Fn[T any] func(context.Context) (T, error)

type Job

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

func NewJob

func NewJob[T any](fn Fn[T], errMsg string) *Job[T]

func (*Job[T]) Result

func (j *Job[T]) Result() (T, error)

func (*Job[T]) Value

func (j *Job[T]) Value() T

func (*Job[T]) ValueOrZero

func (j *Job[T]) ValueOrZero() T

Jump to

Keyboard shortcuts

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