https://github.com/kc596/priorityworkerpool
A worker pool in GoLang which schedules job according to priority.
https://github.com/kc596/priorityworkerpool
go golang golang-library goroutine goroutine-pool goroutinemanager goroutines worker-pool
Last synced: about 1 month ago
JSON representation
A worker pool in GoLang which schedules job according to priority.
- Host: GitHub
- URL: https://github.com/kc596/priorityworkerpool
- Owner: kc596
- License: mit
- Created: 2020-11-01T15:42:50.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2021-09-02T12:24:41.000Z (over 3 years ago)
- Last Synced: 2025-02-28T17:50:54.910Z (about 2 months ago)
- Topics: go, golang, golang-library, goroutine, goroutine-pool, goroutinemanager, goroutines, worker-pool
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 6
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Priority Worker Pool
[](https://travis-ci.org/kc596/priorityworkerpool)
[](https://codecov.io/gh/kc596/priorityworkerpool)
[](https://goreportcard.com/report/github.com/kc596/priorityworkerpool)
[](https://codeclimate.com/github/kc596/priorityworkerpool/maintainability)A worker pool in GoLang which schedules job according to priority.
### Installation
> go get github.com/kc596/priorityworkerpool
### Quickstart
```go
import "github.com/kc596/priorityworkerpool"const (
poolName = "testPool"
numWorkers = 1000
)var panicHandler = func(alias string, err interface{}) {
fmt.Println(alias, err) // or use logger
}pool := priorityworkerpool.New(poolName, numWorkers, panicHandler)
job := func() {
// code to execute
}pool.Submit(job, 1+rand.Float64())
```A complete example : [Here](https://goplay.space/#DIM2U6jBjwY)
### APIs
Method | Return Type | Description
---|---|---
` New(name string, workers int, panicHandler func(alias string, err interface{})`|`*Pool` | Returns a new worker pool
`Submit(job func(), priority float64)` | `void` | Submit a new job to worker pool
`WaitGroup()` | `*sync.WaitGroup` | Returns waitgroup to wait for all jobs submitted to finish
`ShutDown()` | `void` | Delete queue and prevents pickup of next job from the queue