Fix validator bugs
This commit is contained in:
parent
84c99ff732
commit
a5e78e3814
@ -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) {
|
||||
|
Reference in New Issue
Block a user