Skip to content

Commit

Permalink
refactor: use time.After (#41)
Browse files Browse the repository at this point in the history
  • Loading branch information
niklastreml authored Dec 14, 2023
1 parent 7f408eb commit 4472a0b
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 8 deletions.
5 changes: 1 addition & 4 deletions internal/helper/retry.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ func Retry(effector Effector, rc RetryConfig) func(ctx context.Context) error {
delay := getExpBackoff(rc.Delay, r)
log.WarnContext(ctx, fmt.Sprintf("Effector call failed, retrying in %v", delay))

timer := time.NewTimer(delay)
defer timer.Stop() //nolint:gocritic //TODO: check if this is correct

select {
case <-ctx.Done():
return ctx.Err()
case <-timer.C:
case <-time.After(delay):
}
}
}
Expand Down
5 changes: 1 addition & 4 deletions pkg/config/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,10 @@ func (gl *HttpLoader) Run(ctx context.Context) {
log.Info("Successfully got remote runtime configuration")
gl.cCfgChecks <- runtimeCfg.Checks

timer := time.NewTimer(gl.cfg.Loader.Interval)
defer timer.Stop() //nolint:gocritic // TODO: check if this is right

select {
case <-ctx.Done():
return
case <-timer.C:
case <-time.After(gl.cfg.Loader.Interval):
}
}
}
Expand Down

0 comments on commit 4472a0b

Please sign in to comment.