Timer

class Timer @InternalWowApi constructor(val id: String, val owner: AggregateRef, val key: String, val version: Long, val partition: Int, val rule: ScheduleRule, val dueAt: Long, val target: AggregateRef, val commandType: String, val body: String, val slot: Long = 1, val causation: Causation? = null, val headers: Map<String, String> = emptyMap(), val operator: Operator? = null, val status: TimerStatus = TimerStatus.PENDING, val attempts: Int = 0, val outcome: String? = null, val scope: Scope = Scope.NONE, val slotDueAt: Long = dueAt, val skipped: Long = 0)

One schedule of an aggregate: send the command of type commandType, body its JSON, to target each time rule says, the next time dueAt (epoch milliseconds), for its slot, due at slotDueAt.

  • id is ref#key@version, its names escaped, the schedule as the owner's stream at version set it (Timers.idOf); the command of each slot is sent with the request id id#slot (requestId), so sending it again is deduplicated by its target.

  • owner and key name the schedule: the aggregate that set it (Timers.ownerOf), compared field by field, never by its joined name, so two aggregates whose tenant and id join alike keep their timers apart; version orders the owner's changes (TimerStore).

  • slot counts the times the schedule is due, from 1: firing a slot marks it fired and moves dueAt to the next one in one write; a rule due once has one slot, after which the timer is FIRED. A recurring rule's slot is the number of its times since it was set, so slots it skipped (missed and coalesced, me.ahoo.wow.api.schedule.Misfire) are counted too: skipped is how many slots before this one were not sent.

  • slotDueAt is when the current slot is due, as its rule said; dueAt is when the firing loop next looks at the timer: the slot's due time at first, then the claim's deadline while it is sent, or the next attempt after a technical failure. Every send of the slot, retried or claimed anew, carries slotDueAt (context), so its target never decides it before then; it moves only with the slot.

  • partition is the partition of the owner among its context's log partitions: the owner of that partition writes the timer from the owner's events and fires it, and a sharded store shards the timers by it, so the due read and every read or write by owner reach one shard. The command reaches a target owned elsewhere through the cluster channel.

  • causation links the command to the commit that set the schedule; headers and operator are the setting command's, which the command inherits, and scope the setting commit's, the owner and space the command is sent in.

  • status, attempts and outcome record what the firing loop did: outcome is what the target answered (TimerOutcomes), or why a timer is parked.

Fields may be added: construct one with of; the constructor is internal to Wow.

Constructors

Link copied to clipboard
constructor(id: String, owner: AggregateRef, key: String, version: Long, partition: Int, rule: ScheduleRule, dueAt: Long, target: AggregateRef, commandType: String, body: String, slot: Long = 1, causation: Causation? = null, headers: Map<String, String> = emptyMap(), operator: Operator? = null, status: TimerStatus = TimerStatus.PENDING, attempts: Int = 0, outcome: String? = null, scope: Scope = Scope.NONE, slotDueAt: Long = dueAt, skipped: Long = 0)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Which time of the schedule the command of the current slot is sent for, as its target reads it: due at slotDueAt, however many attempts or claims it took.

Link copied to clipboard
val dueAt: Long
Link copied to clipboard
Link copied to clipboard
val id: String
Link copied to clipboard
val key: String
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

The request id the command of the current slot is sent with: id#slot.

Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
val slot: Long
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
fun copyWith(id: String = this.id, owner: AggregateRef = this.owner, key: String = this.key, version: Long = this.version, partition: Int = this.partition, rule: ScheduleRule = this.rule, dueAt: Long = this.dueAt, target: AggregateRef = this.target, commandType: String = this.commandType, body: String = this.body, slot: Long = this.slot, causation: Causation? = this.causation, headers: Map<String, String> = this.headers, operator: Operator? = this.operator, status: TimerStatus = this.status, attempts: Int = this.attempts, outcome: String? = this.outcome, scope: Scope = this.scope, slotDueAt: Long = this.slotDueAt, skipped: Long = this.skipped): Timer

This Timer with the given fields replaced: Wow's own copy, left out of the ABI.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
open override fun toString(): String