Skip to content

Instantly share code, notes, and snippets.

View lidedongsn's full-sized avatar
🐎
Looking for something interesting.

lidedongsn lidedongsn

🐎
Looking for something interesting.
  • Beijing,China
View GitHub Profile
type Dispatcher struct {
// A pool of workers channels that are registered with the dispatcher
WorkerPool chan chan Job
}
func NewDispatcher(maxWorkers int) *Dispatcher {
pool := make(chan chan Job, maxWorkers)
return &Dispatcher{WorkerPool: pool}
}
var (
MaxWorker = os.Getenv("MAX_WORKERS")
MaxQueue = os.Getenv("MAX_QUEUE")
)
// Job represents the job to be run
type Job struct {
Payload Payload
}