ScheduleSlots

The slots of a schedule's rule: when a timer is first due, which slot comes after one that fired, and what a slot missed while no node fired it becomes. The runtime's firing loop, the timers subscription and the test DSL share it, so a schedule steps through its slots the same way wherever it runs.

  • A rule due once (ScheduleRule.At, ScheduleRule.After) has one slot.

  • A ScheduleRule.Cron rule's first slot is the first time after the commit that set it; each next slot is the first time after the slot before it, never after now, so a late firing does not move the period.

  • A slot found past due when it is claimed, or the next slot found past due when one fired, is caught up as the rule's Misfire says: Misfire.COALESCE moves to the latest time due, the ones in between counted in Timer.skipped and never sent; Misfire.CATCH_UP sends each in turn. A slot moved to is always a time its rule names, and it is due at that time (Timer.dueAt and Timer.slotDueAt alike), so how late it is, and whether it expired, is judged from its own time. Beyond MAX_COUNTED missed slots only their count is estimated, from the period.

Properties

Link copied to clipboard
const val MAX_COUNTED: Long

How many missed slots are counted one by one before the rest are estimated.

Functions

Link copied to clipboard
fun afterFired(timer: Timer, now: Long): Timer?

timer after its slot was sent at now: its next slot, PENDING with its attempts reset, or null when its rule has no next time (a rule due once, a cron expression that names no later time) and the timer is done. The next slot is the first time after the slot's own due time; past due already, a coalescing rule moves on to the latest time due.

Link copied to clipboard
fun caughtUp(timer: Timer, now: Long): Timer

timer, about to be claimed at now: a recurring slot past due by more than one time of its rule moves to the latest one due, due at its own time, the others skipped, when its rule coalesces; otherwise timer as it is.

Link copied to clipboard

The parsed expression of rule, cached; an IllegalArgumentException when it is not valid.

Link copied to clipboard
fun firstDue(rule: ScheduleRule, commitTime: Long): Long

When a schedule set by a commit at commitTime is first due: Timers.NOT_EVALUATED when never.

Link copied to clipboard

The first time after after (epoch milliseconds) that rule names, or null when it names none.

Link copied to clipboard
fun timerOf(stream: EventStreamRecord, set: ScheduleSet, partitions: Int): Timer

The timer set, an event of stream, makes in partitions partitions, its first slot evaluated.

Link copied to clipboard

Fails with an IllegalArgumentException unless rule's expression and time zone are valid.

Link copied to clipboard

The time zone of rule; an IllegalArgumentException when it is not one. Not cached: the JDK keeps the rules of each region, and ZoneId.of takes some 20 ns.