https://github.com/savsgio/workerpool
Lightweight and fast worker pool with generics support.
https://github.com/savsgio/workerpool
go golang tool utils worker-pool
Last synced: about 2 months ago
JSON representation
Lightweight and fast worker pool with generics support.
- Host: GitHub
- URL: https://github.com/savsgio/workerpool
- Owner: savsgio
- License: apache-2.0
- Created: 2022-05-30T13:05:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-04-08T10:40:36.000Z (about 2 months ago)
- Last Synced: 2025-04-08T11:33:36.035Z (about 2 months ago)
- Topics: go, golang, tool, utils, worker-pool
- Language: Go
- Homepage:
- Size: 20.5 KB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# workerpool
[](https://github.com/savsgio/workerpool/actions?workflow=test)
[](https://goreportcard.com/report/github.com/savsgio/workerpool)
[](https://pkg.go.dev/github.com/savsgio/workerpool)Lightweight and fast worker pool with generics support.
Go version: >=1.18
Based on: [valyala/fasthttp/workerpool.go](https://github.com/valyala/fasthttp)
## Example:
```go
type Foo struct {
A int
B int
}wg := sync.WaitGroup{}
handler := func(args Foo) {
log.Println(args.A + args.B)
wg.Done()
}wp := New(
Config{
MaxWorkersCount: 100,
MaxIdleWorkerDuration: 5 * time.Second,
},
handler,
)for i := 0; i < 10; i++ {
wg.Add(1)
wp.Exec(Foo{A: i, B: i + 1})
}wg.Wait()
```