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.
Click to show internal directories.
Click to hide internal directories.