summaryrefslogtreecommitdiff
path: root/internal/server/continuous.go
diff options
context:
space:
mode:
authorPaul Buetow <paul@buetow.org>2026-03-04 21:37:09 +0200
committerPaul Buetow <paul@buetow.org>2026-03-04 21:37:09 +0200
commit0bc4eaebd646e9577145be0f09ef09fb77c51f22 (patch)
treea333dc48418041d7331545d55c1e6d271eaba312 /internal/server/continuous.go
parent2393a41e6b9f6e5ffa7a212a1727c1a1a7bf64d9 (diff)
fix: replace looped time.After with reusable tickers (task 359)
Diffstat (limited to 'internal/server/continuous.go')
-rw-r--r--internal/server/continuous.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/server/continuous.go b/internal/server/continuous.go
index 90e5f8a..3178240 100644
--- a/internal/server/continuous.go
+++ b/internal/server/continuous.go
@@ -35,10 +35,12 @@ func (c *continuous) runJobs(ctx context.Context) {
}
go func(job config.Continuous) {
c.runJob(ctx, job)
+ retryTicker := time.NewTicker(time.Minute)
+ defer retryTicker.Stop()
for {
select {
- // Retry after a minute
- case <-time.After(time.Minute):
+ // Retry after a minute.
+ case <-retryTicker.C:
c.runJob(ctx, job)
case <-ctx.Done():
return
@@ -98,9 +100,11 @@ func (c *continuous) runJob(ctx context.Context, job config.Continuous) {
func (c *continuous) waitForDayChange(ctx context.Context) bool {
startTime := time.Now()
+ checkTicker := time.NewTicker(time.Second)
+ defer checkTicker.Stop()
for {
select {
- case <-time.After(time.Second):
+ case <-checkTicker.C:
if time.Now().Day() != startTime.Day() {
return true
}