https://github.com/raidancampbell/go-workpool
A workpool management system that retains order
https://github.com/raidancampbell/go-workpool
go golang threadpool workpool
Last synced: 7 months ago
JSON representation
A workpool management system that retains order
- Host: GitHub
- URL: https://github.com/raidancampbell/go-workpool
- Owner: raidancampbell
- License: bsd-3-clause
- Created: 2020-03-28T16:50:44.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2020-03-29T05:21:18.000Z (about 6 years ago)
- Last Synced: 2025-09-25T00:32:27.332Z (7 months ago)
- Topics: go, golang, threadpool, workpool
- Language: Go
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-workpool
[](https://goreportcard.com/report/github.com/raidancampbell/go-workpool)
[](https://godoc.org/github.com/raidancampbell/go-workpool)
```go
import github.com/raidancampbell/go-workpool
```
`go-workpool` provides a pool-of-work pattern, to synchronize events before passing them to an asynchronous/parallel processing pipeline.
For example, if you have 3 events:
1. an account creation for account `a`
2. an account update for account `a`
3. an account update for account `b`
Events 1 and 3 can be processed simultaneously, while event 2 must wait until event 1 is complete.
### Usage
A workpool is instantiated via `workpool.New()`. The workpool expects submitted work to implement the `Work` interface. This interface has a `Key()` function to return a string (`"a"` or `"b"` in the above example), and has a `Do()` function to perform whatever work is required. The `workpool_test.go` file contains some simple examples.