Skip to content

Commit

Permalink
Update forwarder to use time.Timer
Browse files Browse the repository at this point in the history
  • Loading branch information
hibiken committed Apr 11, 2022
1 parent ed69667 commit 088be63
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion forwarder.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,15 @@ func (f *forwarder) start(wg *sync.WaitGroup) {
wg.Add(1)
go func() {
defer wg.Done()
timer := time.NewTimer(f.avgInterval)
for {
select {
case <-f.done:
f.logger.Debug("Forwarder done")
return
case <-time.After(f.avgInterval):
case <-timer.C:
f.exec()
timer.Reset(f.avgInterval)
}
}
}()
Expand Down

0 comments on commit 088be63

Please sign in to comment.