concurrency

package
v0.42.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunInWorkerPool

func RunInWorkerPool[T any](
	ctx context.Context,
	data datacontext.Context,
	tasks []T,
	f func(ctx context.Context, task T) error,
) error

RunInWorkerPool runs f(task) concurrently for each element in tasks, using up to maxWorkers workers. It waits for all tasks to complete and returns a joined error if any of them fail.

If workers are set to 0 or 1, instead of spawning a traditional worker pool the tasks are run sequentially in order of task input. In this case, the returned error is the first error encountered, if any.

For multiple workers, the worker pool does NOT cancel remaining tasks on first failure; all tasks run to completion. Context cancellation will stop idle workers but not interrupt running ones.

Types

This section is empty.

Jump to

Keyboard shortcuts

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