diff --git a/ops/validator.go b/ops/validator.go index 03371ba..4e443cf 100644 --- a/ops/validator.go +++ b/ops/validator.go @@ -19,17 +19,15 @@ type Validator struct { Logger tacitus.Logger Products []string - done chan struct{} - dirty bool + 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) {