ScheduleModule

PackageFCQRS.Workflows
The schedule aggregate's rules. One aggregate instance holds one schedule.

Summary

NameSignatureSynopsis
EntityNameEntityName The aggregate's entity name.
initialinitial The state before the schedule's first event.
OnTimeWindowOnTimeWindow How late a `Fire` may arrive for a due time and still be on time under `CatchUp.None`: one minute.
EarlyToleranceEarlyTolerance How early a `Fire` may arrive for a due time: one second, which covers timer imprecision.
allowedDueallowedDue state nowThe one due time a `Fire` arriving at `now` may name, or nothing for a schedule that does not exist, is deleted or is paused.
decidedecide command stateChooses what to do with a command.
foldfold event stateApplies one event.

EntityName

EntityName
Member
The aggregate's entity name. A persistent contract.

Returns

string

initial

initial
Member
The state before the schedule's first event.

Returns

ScheduleState

OnTimeWindow

OnTimeWindow
Member
How late a `Fire` may arrive for a due time and still be on time under `CatchUp.None`: one minute. A due time more than a minute old when its `Fire` arrives was missed, and `CatchUp.None` skips it. For a rule whose due times are less than a minute apart, a gap shorter than a minute therefore runs its latest due time, as `CatchUp.Latest` does.

Returns

TimeSpan

EarlyTolerance

EarlyTolerance
Member
How early a `Fire` may arrive for a due time: one second, which covers timer imprecision. A `Fire` that arrives earlier is refused and changes nothing, so a dispatcher fault cannot start a run more than a second early. The same due time is accepted when its time comes.

Returns

TimeSpan

allowedDue

allowedDue state now
Member
The one due time a `Fire` arriving at `now` may name, or nothing for a schedule that does not exist, is deleted or is paused. It is the next due time after the last accepted one, the creation, the last change and the last resume. When that due time has already passed, the catch-up policy chooses among the passed ones: `Latest` the most recent, `All` the oldest of the most recent `ScheduleRule.MaxMissed`, and `None` the most recent if it passed within `OnTimeWindow`, otherwise the next due time after `now`. The result can be later than `now`: `decide` accepts it only from `EarlyTolerance` before it. A pending `Firing` is not checked here.

Parameters

NameTypeDescription
stateScheduleState
nowDateTime

Returns

DateTime option

decide

decide command state
Member
Chooses what to do with a command. The command's `CreationDate` is the current time. A refusal is a deferred `Refused`. A repeat of an accepted command is answered with a deferred copy of the first verdict, checked before anything the first command changed. A spec that fails validation, or a due time that cannot be computed, is refused: decide raises nothing.

Parameters

NameTypeDescription
commandCommand<ScheduleCommand>
stateScheduleState

Returns

EventAction<ScheduleEvent>

fold

fold event state
Member
Applies one event. It runs for stored events and for deferred replies, so a refusal or a repeated reply changes nothing.

Parameters

NameTypeDescription
eventEvent<ScheduleEvent>
stateScheduleState

Returns

ScheduleState