---
# System prepended metadata

title: worker pool

---

# worker pool

Implement and test a worker pool.
- It has as parameters, 
    - `MAX_GOROUTINES`: the max number of worker goroutines.
    - `TASK_TIMEOUT`: the max duration a task can spend on any worker.
    - `SHUTDOWN_TIMEOUT`: the time to wait for all running tasks to finish before shutting down.
- The worker pool accepts a function (`task`) to its pool. The task should run for a max of `TASK_TIMEOUT` duration.
- It also accepts a `callback` to fire when the task is done (on successful run or error)
- Upon shutdown, the worker should discard all `non-running` tasks but should wait a duration of at most `SHUTDOWN_TIMEOUT` for the `running` tasks to finish.



## Testing
 - Add unit tests
 - Benchmark your workerpool with varying parameters.
