Maistry is a Golang implementation of Worker Pool. Effective when you have limited worker resources but has Jobs/functions to execute across multiple use-cases with customizable requests-per-second.
go get github.com/govindamurali/maistry
- Job - Essentially a func() to be executed
- Worker - Does a job.
- Job Manager - This generates the jobs. Takes in two parameters, jobsPerSecond and a name.
- Dispatcher - Dispatches the jobs to the workers. Takes in maxWorkers as the input, and a logger interface with standard Error and Info.
dispatcher := maistry.NewDispatcher(workerCount, logger)
dispatcher.Start()
jm1:= maistry.NewJobManager(jps1, "manager 1")
jm2:= maistry.NewJobManager(jps2, "manager 2")
jm1.Run()
jm2.Run()
job1 := maistry.NewJob(
func() {
//your function here
}, logger)
jm1.PushJob(job1)
job2 := maistry.NewJob(func() {
//your other function here
}, logger)
jm2.PushJob(job2)