Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lbrulet/go-routine
Go worker pool to handle jobs
https://github.com/lbrulet/go-routine
channel go golang worker-pool
Last synced: about 6 hours ago
JSON representation
Go worker pool to handle jobs
- Host: GitHub
- URL: https://github.com/lbrulet/go-routine
- Owner: lbrulet
- Created: 2020-03-26T03:49:35.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-03-26T11:37:04.000Z (over 4 years ago)
- Last Synced: 2024-06-19T04:17:11.847Z (5 months ago)
- Topics: channel, go, golang, worker-pool
- Language: Go
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Go routine
Go routine is a program to handle a pool of workers with go channel.
## Usage
Start the pool with a pool of 10 workers and 10 jobs that will be created.
Here is the output.
```bash
go run cmd/main.go -workers 10 -jobs 10
020/03/26 15:53:07 [INFO] starting HTTP server on port :9009
2020/03/26 15:53:07 [INFO] starting 10 jobs
2020/03/26 15:53:07 [INFO] starting 10 workers
2020/03/26 15:53:07 [workerID:2][email_job] Processed job in 0.023 seconds
2020/03/26 15:53:07 [workerID:3][email_job] Processed job in 0.020 seconds
2020/03/26 15:53:07 [workerID:4][email_job] Processed job in 0.021 seconds
2020/03/26 15:53:07 [workerID:5][email_job] Processed job in 0.021 seconds
2020/03/26 15:53:07 [workerID:9][notification_job] Processed job in 0.062 seconds
2020/03/26 15:53:07 [workerID:7][email_job] Processed job in 0.020 seconds
2020/03/26 15:53:07 [workerID:0][notification_job] Processed job in 0.062 seconds
2020/03/26 15:53:07 [workerID:1][notification_job] Processed job in 0.061 seconds
2020/03/26 15:53:07 [workerID:6][notification_job] Processed job in 0.062 seconds
2020/03/26 15:53:07 [workerID:8][notification_job] Processed job in 0.062 seconds
```You can also push a random job to the pool with an endpoint
```bash
curl localhost:9009/new-job
```