in pkg/sync/pool/pool.go [263:298]
func (p *Pool) Start() error {
if p.Status() > StoppedStatus && p.Status() < StoppedTimeout {
return ErrAlreadyStarted
}
if !p.state.monitoring {
go p.monitor(nil)
}
// If the pool was previously stopped, recreate the channels
if p.Status() > StoppedTimeout {
if len(p.queue) == 0 {
p.queue = make(chan Validator, cap(p.queue))
}
if len(p.leftovers) == 0 {
p.leftovers = make(chan Validator, cap(p.leftovers))
}
}
p.setStatus(StartingStatus)
for worker := 0; worker < int(p.size); worker++ {
<-StartWorker(Worker{
Queue: p.queue,
Stop: p.signals.Stop,
Stopped: p.signals.Stopped,
Finished: p.signals.Finish,
Errors: p.errors,
Leftovers: p.leftovers,
Run: p.run,
StopTimeout: p.timeouts.Stop,
})
}
return nil
}