thread

package
v1.47.2 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2024 License: Apache-2.0 Imports: 5 Imported by: 14

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Parallelism

func Parallelism() int

Parallelism returns the current parellism.

This defaults to the number of CPUs.

func Parallelize

func Parallelize(ctx context.Context, jobs []func(context.Context) error, options ...ParallelizeOption) error

Parallelize runs the jobs in parallel.

A max of Parallelism jobs will be run at once. Returns the combined error from the jobs.

func SetParallelism

func SetParallelism(parallelism int)

SetParallelism sets the parallelism.

If parallelism < 1, this sets the parallelism to 1.

Types

type ParallelizeOption added in v0.55.0

type ParallelizeOption func(*parallelizeOptions)

ParallelizeOption is an option to Parallelize.

func ParallelizeWithCancelOnFailure added in v1.38.0

func ParallelizeWithCancelOnFailure() ParallelizeOption

ParallelizeWithCancelOnFailure returns a new ParallelizeOption that will attempt to cancel all other jobs via context cancellation if any job fails.

func ParallelizeWithMultiplier added in v0.55.0

func ParallelizeWithMultiplier(multiplier int) ParallelizeOption

ParallelizeWithMultiplier returns a new ParallelizeOption that will use a multiple of Parallelism() for the number of jobs that can be run at once.

The default is to only do Parallelism() number of jobs. A multiplier of <1 has no meaning.

Jump to

Keyboard shortcuts

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