Skip to content

schedulemanager: add nextRunTime math for per-schedule jobs - #4606

Merged
mastercactapus merged 1 commit into
masterfrom
sched-jobs/p3d-next-run-time
Oct 27, 2026
Merged

mastercactapus merged 1 commit into
masterfrom
sched-jobs/p3d-next-run-time

Conversation

@mastercactapus

Copy link
Copy Markdown
Member

Description:
Adds a helper function that calculates the next time a schedule will change (i.e., when it should be scheduled for update)

Pure time math with no production callers yet (part of #4245):

- MaxLookAhead (1h) bounds how far a schedule job schedules its
  successor; runGranularity (1m) must match the River ByPeriod used
  when inserting it.
- timeSpan and ceilTo are small helpers for the candidates and the
  final rounding.
- nextRunTime picks the earliest of rule boundaries (Rule.NextChange in
  the schedule zone), span edges, notification times and the
  grid-aligned look-ahead clamp (next whole lookAhead boundary in UTC,
  so concurrent jobs for one schedule agree on the target), pre-empted
  by any zone transition before it, rounded up to the minute in UTC.

The result is always strictly after now and its minute bucket strictly
advances, so a successor is never due at or before the job that
scheduled it. TestCeilTo and TestNextRunTime (most of the diff) cover the
rounding, the grid clamp, span and notification candidates, DST
transitions (Chicago, Santiago) and that post-condition.

Signed-Off-By: Nathaniel Caza <mastercactapus@gmail.com>
@mastercactapus
mastercactapus merged commit 154e357 into master Oct 27, 2026
9 checks passed
@mastercactapus
mastercactapus deleted the sched-jobs/p3d-next-run-time branch October 27, 2026 14:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants