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 FROM_INPUT: String

What a refusal of a schedule's rule set by code says of a rule that came from input.

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

Why rule, the rule of the schedule key, cannot run: a cron rule whose expression or time zone cannot be read, or that names no time that ever comes (requireFires); null when it can. The rule of a schedule that comes in new is checked by it where it is set, never a rule already stored.

Link copied to clipboard

Fails with an IllegalArgumentException unless rule is valid (validate) and names a time that ever comes, the reason naming its expression and time zone. next looks CronExpression.MAX_YEARS years ahead, a whole cycle of the Gregorian calendar, so a rule without a time in them has none ever: 0 0 0 30 2 * and 0 0 0 31 4 * are refused, while 0 0 0 29 2 * comes every fourth year and a local time a zone's change skips on one day comes on the others. A rule that comes finds its first time within its own period (at most eight years for 29 February, some microseconds); one that never comes costs a step per day of its months for those 400 years, under a millisecond (about 0.1 ms for 30 February, 0.4 ms for the 31st of five 30-day months).

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: counted from when the commit was written (EventStreamRecord.writtenAt), as Timers.of counts.

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.