Bounded Worker Pool
A fixed set of goroutines and a bounded queue, with blocking, non-blocking, and context-aware submits
A bounded worker pool with retries, panic recovery, and graceful shutdown — plus typed futures, error groups, batching, a cron scheduler, and flow-control helpers. Standard library only.
go get github.com/KARTIKrocks/go-workerA fixed set of goroutines and a bounded queue, with blocking, non-blocking, and context-aware submits
Exponential backoff, a delay cap, jitter, per-attempt timeouts, and permanent errors that skip retrying
A panicking job returns a PanicError with its stack trace; the worker keeps running
Drain the queue on Close, or force-cancel in-flight jobs after a timeout
Submit a func returning (T, error) and await a typed result, with generics
Fan out with error collection or cancel-on-first-error, and process slices in chunks
Cron expressions, intervals, daily times, and one-shot tasks with overlap policies and jitter
Ticker, debouncer, throttler, and token-bucket rate limiter, all on top of the pool
Wrap every attempt for tracing or logging, and observe job and worker lifecycles
Atomic counters for submitted, completed, failed, retried, and panicked jobs, plus throughput
Stop picking up new work without shutting down, then carry on where you left off
Standard library only — nothing to audit, nothing to update
A go statement and a sync.WaitGroup get you concurrency. Running background work safely in production — bounded, retried, cancellable, observable, and shut down cleanly — is the part go-worker provides.
| Capability | go-worker | Goroutines + WaitGroup |
|---|---|---|
| Bounded concurrency and backpressure | Included | You build it |
| Retries with backoff, jitter, and permanent errors | Included | You build it |
| Panic recovery with stack traces | Included | You build it |
| Per-attempt timeouts and cancellation | Included | You build it |
| Graceful drain and forced shutdown | Included | You build it |
| Cron, interval, and one-shot scheduling | Included | You build it |
| Debounce, throttle, and rate limiting | Included | You build it |
| Metrics and lifecycle hooks | Included | You build it |
Measured on an Intel i5-11400H (12 cores), Go 1.27, Linux, with an 8-worker pool and 12 goroutines submitting no-op jobs concurrently — so these figures are the pool's own overhead, not your jobs'.
0.9 µs/op
5 allocs, sustained with a full queue
1.5 µs/op
8 allocs, including the result handoff
~1.1M jobs/s
no-op jobs, 8 workers
0
standard library only
Reproduce them yourself with go test -bench=. -benchmem ./... in the repository root. The benchmark table in the README lists every figure measured.