jobs

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2024 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const WorkBuffer = 100

Variables

View Source
var ErrStream = errors.New("executing workflow")

Functions

func Parallel added in v0.2.0

func Parallel(parallel int) func(*Runner)

Types

type Runner

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

func NewRunner

func NewRunner(opts ...RunnerOpt) *Runner

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, cancel context.CancelCauseFunc, workQueue WorkQueue) *sync.WaitGroup

Run launches goroutines that execute work in workQueue. Returns a WaitGroup that completes when all work is done. Halts and marks WaitGroup as done on error.

type RunnerOpt added in v0.2.0

type RunnerOpt func(*Runner)

type Work added in v0.2.0

type Work func() error

type WorkQueue added in v0.2.0

type WorkQueue <-chan Work

func Filter added in v0.2.0

func Filter[T any](buffer int, in <-chan T, predicate func(T) (bool, error)) (<-chan T, WorkQueue)

Filter discards elements which do not cause predicate to return true.

func ForEach added in v0.2.0

func ForEach[FROM any](buffer int, in <-chan FROM, fn func(FROM) error) WorkQueue

ForEach performs an action for each item, returning nothing.

func Map added in v0.2.0

func Map[FROM, TO any](buffer int, in <-chan FROM, fn func(FROM) (TO, error)) (<-chan TO, WorkQueue)

Map mutates an input channel, optionally changing the type.

func Reduce added in v0.2.0

func Reduce[T any](buffer int, in <-chan T, fn func(T) error) WorkQueue

Reduce consumes a channel.

Jump to

Keyboard shortcuts

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