Fix validator bugs

This commit is contained in:
Kevin Cotugno 2017-10-19 21:55:42 -07:00
parent 84c99ff732
commit a5e78e3814

View File

@ -20,16 +20,14 @@ type Validator struct {
Products []string
done chan struct{}
stopped bool
dirty bool
}
func (v *Validator) Stop() {
if v.done != nil {
select {
case v.done <- struct{}{}:
default:
}
if v.done != nil && !v.stopped {
v.done <- struct{}{}
v.stopped = true
}
}
@ -52,6 +50,7 @@ func (v *Validator) Start(frequency time.Duration) {
for !done {
select {
case <-v.done:
v.Logger.Info("Done")
done = true
ticker.Stop()
case <-ticker.C:
@ -81,7 +80,6 @@ func (v *Validator) emitProducts(done chan struct{}) {
}
}()
}
func (v *Validator) validateProduct(product string) {