https://github.com/tcfw/go-queue
Chan based queue worker
https://github.com/tcfw/go-queue
channels go golang queues worker-pool
Last synced: 6 months ago
JSON representation
Chan based queue worker
- Host: GitHub
- URL: https://github.com/tcfw/go-queue
- Owner: tcfw
- License: mit
- Created: 2018-10-22T02:23:04.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2020-09-22T22:19:50.000Z (over 5 years ago)
- Last Synced: 2025-02-24T16:51:14.880Z (11 months ago)
- Topics: channels, go, golang, queues, worker-pool
- Language: Go
- Homepage:
- Size: 9.77 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Go-Queue
[](https://pkg.go.dev/github.com/tcfw/go-queue)
[](https://goreportcard.com/report/github.com/tcfw/go-queue)
A simple generic chan based queue worker
## License
Please refer to [LICENSE.md](https://github.com/tcfw/go-queue/LICENSE.md)
## Examples
### Simple example
```
package main
import (
queue "github.com/tcfw/go-queue"
)
type Processor struct {}
func (p *Processor) Handle(job interface{}) {
//Handle job...
}
func main() {
processor := &Processor{}
dispatcher := queue.NewDispatcher(processor)
dispatcher.Run()
}
```
### Specify number of workers
```
package main
import (
queue "github.com/tcfw/go-queue"
)
type Processor struct {}
func (p *Processor) Handle(job interface{}) {
//Handle job...
}
func main() {
processor := &Processor{}
dispatcher := queue.NewDispatcher(processor)
//20 workers will be created
dispatcher.MaxWorkers = 20
dispatcher.Run()
}
```