diff options
Diffstat (limited to 'internal/scheduler/buckets.go')
| -rw-r--r-- | internal/scheduler/buckets.go | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/internal/scheduler/buckets.go b/internal/scheduler/buckets.go new file mode 100644 index 0000000..5fa242d --- /dev/null +++ b/internal/scheduler/buckets.go @@ -0,0 +1,33 @@ +package scheduler + +import ( + "context" + "log" + "time" + + "task-dashboard/internal/config" + "task-dashboard/internal/store" +) + +// RunBucketCycleCheck ticks every interval, calling RunBucketCycles until +// ctx is cancelled. Mirrors RunRecurrenceCheck's shape -- errors are +// logged, not fatal, so one bad tick doesn't kill the loop. +func RunBucketCycleCheck(ctx context.Context, s *store.Store, interval time.Duration) { + ticker := time.NewTicker(interval) + defer ticker.Stop() + for { + select { + case <-ctx.Done(): + return + case <-ticker.C: + n, err := s.RunBucketCycles(config.Now()) + if err != nil { + log.Printf("ERROR [BucketCycleCheck]: %v", err) + continue + } + if n > 0 { + log.Printf("BucketCycleCheck: activated %d item(s)", n) + } + } + } +} |
