Documentation
¶
Overview ¶
Package worker contains functionality to parallelize tasks with a pool of workers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChangeHandler ¶ added in v0.1.6
type ChangeHandler func(submitted, completed, errors int)
ChangeHandler is updated when the worker pool increases the number of submitted, completed, or error jobs.
type ErrorHandler ¶ added in v0.2.0
ErrorHandler is updated when the worker pool encounters an error. The encountered error will be replaced with the return value of the handler.
type Pool ¶
type Pool[T any] struct { Workers int OnChange ChangeHandler OnError ErrorHandler FailFast bool // contains filtered or unexported fields }
Pool is a pool of workers.
func (*Pool[T]) Error ¶
Error waits for all submitted jobs to finish, closes the submission channel, and returns whether any of the jobs produced an error.
Must be called after all jobs are added.
Click to show internal directories.
Click to hide internal directories.