fix lint errors

This commit is contained in:
Darien Raymond committed 2018-04-11 16:15:29 +02:00
1 parent 044c641d7b
commit 9d7f43a299
11 files changed
+87 -66

No files matched your search

+5 -1
View File
@@ -11,6 +11,8 @@ type PeriodicTask struct {
Interval time.Duration
// Execute is the task function
Execute func() error
// OnFailure will be called when Execute returns non-nil error
OnError func(error)
access sync.Mutex
timer *time.Timer
@@ -30,7 +32,9 @@ func (t *PeriodicTask) checkedExecute() error {
}
t.timer = time.AfterFunc(t.Interval, func() {
t.checkedExecute()
if err := t.checkedExecute(); err != nil && t.OnError != nil {
t.OnError(err)
}
})
return nil