ScheduleJobModel

The built-in aggregate that keeps a context's jobs: <context>.schedule, one instance per job in its tenant (the default tenant for a JobScope.SYSTEM job), whose id is the job's name, or, for a JobScope.SHARDED job, one per log partition in the default tenant (shardRef): instanceIds are a job's instances' ids. It belongs to its tenant (no owner), has no lifecycle commands, and decides:

  • wow.schedule.Enable(job, rule?): creates the instance or enables it again, with the job's default rule under its own override (the command's, else the one it kept); unchanged, nothing. It schedules its own wow.schedule.Tick under the key tick by that rule, so the firing loop of the partition's owner sends it each slot.

  • wow.schedule.Reschedule(rule?): an enabled instance's own override, null to follow the default again.

  • wow.schedule.Disable: cancels the schedule.

  • wow.schedule.Tick, sent by the schedule: commits wow.Ticked(slot) when the slot is newer than the last one it ran, of the same timer or a later one; an older or repeated slot, or a disabled instance, changes nothing. The tick also reschedules an instance whose rule is no longer its job's default under its override: one that did not override a part follows a change of the default from its next tick. A tick of a job the node no longer has disables the instance.

An Enable that names an unknown job, a job of another scope (a SYSTEM or a SHARDED job outside the default tenant), another instance's id, or an invalid rule, and a Reschedule of an instance that is not enabled, are rejected with FrameworkCodes.SCHEDULE_JOB_INVALID.

Functions

Link copied to clipboard
fun instanceIds(context: String, job: ScheduleJob, partitions: Int): Set<String>

The ids of job's instances in context, whose log has partitions partitions: its name, in each tenant, or, for a JobScope.SHARDED job, its instance's id in each partition (shardRef). Its subscription reads these aggregates alone.

Link copied to clipboard

The model of context's job aggregate, deciding for jobs.

Link copied to clipboard
fun refOf(context: String, job: String, tenantId: String = Caller.DEFAULT_TENANT): AggregateRef

The instance of job in tenantId of context: its id is the job's name.

Link copied to clipboard
fun shardRef(context: String, job: String, partition: Int, partitions: Int): AggregateRef

The instance of the JobScope.SHARDED job of context for the log partition partition of partitions: the first id <job>~<partition>~<n> that lies in that partition, so its ticks run on the partition's owner.