Documentation
¶
Overview ¶
Package workerpool provides a generic buffered worker pool: items submitted via Submit are fanned out across a fixed number of worker goroutines, each running the handler.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ErrStopped = errors.New("workerpool: stopped")
ErrStopped is returned by Submit when the pool is stopped.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*options)
func WithCapacity ¶
WithCapacity sets the number of items buffered before Submit blocks.
func WithRateLimit ¶
WithRateLimit caps how fast items are handled across all workers.
func WithWorkers ¶
WithWorkers sets the number of goroutines running the handler.
type Pool ¶
type Pool[T any] struct { // contains filtered or unexported fields }
func (*Pool[T]) Stop ¶
Stop rejects new submissions, handles buffered items and waits for the workers to finish. If ctx is done first, its error is returned and workers may still be running; calling Stop again waits again.
Click to show internal directories.
Click to hide internal directories.