owner: owner,
clock: clock,
logger: logger,
- check: scheduleCheck,
changed: make(chan struct{}, 1),
}
owner string
clock func() time.Time
logger *slog.Logger
- check time.Duration
changed chan struct{}
mutex sync.Mutex
}
// Run starts the runs of the due schedules in l until ctx ends. It waits until
-// the first due time, at most check at a time, and also wakes at a set or a
-// remove. So a schedule that came due while the daemon was stopped runs at the
-// start. It returns the error of a write of the log or of the file.
+// the first due time, at most scheduleCheck at a time, and also wakes at a set
+// or a remove. So a schedule that came due while the daemon was stopped runs at
+// the start. It returns the error of a write of the log or of the file.
func (s *Schedules) Run(ctx context.Context, l *TurnLoop) error {
for {
err := s.deliver(ctx, l)
wait, found := s.Wait(s.clock())
if found {
- timer = time.NewTimer(min(wait, s.check))
+ timer = time.NewTimer(min(wait, scheduleCheck))
timeout = timer.C
}