A task process pool to allow for the easy creation of a pool of workers.
The recommended way to install go-dependency
get github.com/icambridge/cartel
How import the package
import (
"github.com/icambridge/cartel"
)
Create your own Task
type MockTask struct {
Name string
}
func (mt MockTask) Execute() interface{} {
return MockOutput{mt.Name}
}
Then to use
p := cartel.NewPool(cartel.PoolOptions{Size: 1})
task := MockTask{"Iain"}
p.Do(task)
p.End()
value := <-p.Output