Documentation
¶
Overview ¶
Package workerpool implements Run function - a worker pool implementation, which supports:
- up to `n` adjustable workers;
- limit error up to `m` - pool stops after reaching the error limit;
- panic protection for each worker - each panic counts as an error, worker continues processing.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrErrorsLimitExceeded is an error indicating that the limit of errors is exceeded. ErrErrorsLimitExceeded = errors.New("errors limit exceeded") // ErrNoWorkers is an error indicating that no workers were set. ErrNoWorkers = errors.New("no workers set") // ErrNoTasks is an error indicating that no tasks were set. ErrNoTasks = errors.New("no tasks set") )
Functions ¶
func Run ¶
Run starts tasks in n goroutines and stops its work when receiving m errors from tasks. Values m <= 0 are treated as a scenario where all errors are ignored.
Panics are gracefully handled, each of them is treated as a simple error.
If no tasks are set or n <= 0 it returns ErrNoTasks or ErrNoWorkers respectively.
It returns ErrErrorsLimitExceeded if the error limit is reached.
Types ¶
Click to show internal directories.
Click to hide internal directories.