A compact worker pool for Go applications that want predictable task execution with graceful shutdown semantics.
- Fixed Worker Pool: Start a pool with a stable number of workers.
- Graceful Shutdown: Stop accepting new tasks and wait for queued work to finish.
- Context-Aware Tasks: Pass a shared context into each task function.
- Small API Surface: Keep submission and shutdown logic easy to reason about.
go get github.com/mirkobrombin/go-workerpackage main
import (
"context"
"fmt"
"github.com/mirkobrombin/go-worker/pkg/worker"
)
func main() {
pool := worker.NewPool(2)
defer pool.Shutdown()
pool.Submit(func(ctx context.Context) error {
fmt.Println("working")
return nil
})
}This project is licensed under the MIT License. See the LICENSE file for details.