async

package
v0.12.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2022 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Watcher added in v0.7.2

func Watcher(ctx context.Context, frequency time.Duration) *watcher

Types

type Job

type Job sync.WaitGroup

A Job provides a top level API above the sync.WaitGroup.

job := new(async.Job)
for _, action := range jobs {
	job.Do(action, logger)
}
job.Wait()

It looks a little bit similar to the golang.org/x/sync/errgroup.

func (*Job) Do

func (job *Job) Do(action func() error, handler func(error))

Do calls the given function in a new goroutine. If an error is not nil, it passes it to the handler.

func (*Job) Wait

func (job *Job) Wait()

Wait blocks until the sync.WaitGroup counter is zero.

Jump to

Keyboard shortcuts

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