leaking ticker

pull/178/head
Karolis Rusenas 2018-03-31 14:23:07 +01:00
parent 5c4d63daa0
commit 67ca5f13f7
1 changed files with 5 additions and 4 deletions

View File

@ -57,11 +57,14 @@ func (s *DefaultManager) Start(ctx context.Context) error {
}).Error("trigger.poll.manager: scan failed")
}
for _ = range time.Tick(time.Duration(s.scanTick) * time.Second) {
ticker := time.NewTicker(time.Duration(s.scanTick) * time.Second)
defer ticker.Stop()
for {
select {
case <-ctx.Done():
return nil
default:
case <-ticker.C:
log.Debug("performing scan")
err := s.scan(ctx)
if err != nil {
@ -71,8 +74,6 @@ func (s *DefaultManager) Start(ctx context.Context) error {
}
}
}
return nil
}
func (s *DefaultManager) scan(ctx context.Context) error {