Skip to content

Commit

Permalink
chore: improve ticker
Browse files Browse the repository at this point in the history
  • Loading branch information
andig committed Dec 19, 2024
1 parent 597eeeb commit b172eb2
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions provider/watchdog.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,14 @@ func NewWatchDogFromConfig(ctx context.Context, other map[string]interface{}) (P
}

func (o *watchdogProvider) wdt(ctx context.Context, set func() error) {
tick := time.NewTicker(o.timeout / 2)
for range tick.C {
for tick := time.Tick(o.timeout); ; {
select {
case <-ctx.Done():
tick.Stop()
return
default:
case <-tick:
if err := set(); err != nil {
o.log.ERROR.Println(err)
}
case <-ctx.Done():
return
}
}
}
Expand Down

0 comments on commit b172eb2

Please sign in to comment.