Documentation
¶
Overview ¶
Package worker provides a concurrent task execution system with a configurable number of workers.
It allows for controlled parallel execution of tasks while managing resources efficiently through a semaphore-based worker pool. Key features include:
- Configurable maximum number of concurrent workers - Non-blocking task submission - Graceful shutdown capabilities - Error collection and aggregation - Thread-safe operations
The Pool struct manages a pool of workers that can execute tasks concurrently while limiting the number of goroutines running simultaneously. This prevents resource exhaustion while maximizing throughput.
This implementation is particularly useful for scenarios where you need to process many independent tasks with controlled parallelism, such as in infrastructure management tools, batch processing systems, or any application requiring concurrent execution with resource constraints.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Pool ¶
type Pool struct {
// contains filtered or unexported fields
}
Pool manages concurrent task execution with a configurable number of workers
func NewWorkerPool ¶
NewWorkerPool creates a new worker pool with the specified maximum number of concurrent workers
func (*Pool) GracefulStop ¶
GracefulStop waits for all tasks to complete before stopping the pool
func (*Pool) IsStopping ¶
IsStopping returns whether the pool is in the process of stopping
func (*Pool) Stop ¶
func (wp *Pool) Stop()
Stop shuts down the worker pool after current tasks are completed