SchedulesModule

PackageFCQRS.Workflows
Schedules that start a registered workflow at each due time. A schedule is created, changed, paused, resumed and deleted while the application runs, and is stored in the journal as an aggregate named "fcqrs-schedule". The run for a due time is a workflow instance whose ID is the schedule's ID, "@", and the due time in UTC in ISO 8601 ("O") form. A run starts at least once per accepted due time, and a repeated start with its ID stores nothing.

Summary

NameSignatureSynopsis
MaxIdLengthMaxIdLength The longest schedule ID, in characters: a run ID adds "@" and 28 characters of due time, the correlation IDs of a run's commands add up to 8 more, and a correlation ID holds at most 255.
MaxPersistenceIdLengthMaxPersistenceIdLength The longest persistence ID: 255 characters, the size of the journal's column on PostgreSQL.
registerregister api runsRegisters the schedule aggregate and starts this actor system's dispatcher, which may start the listed workflows.
createcreate handle id workflow input rule catchUpCreates the schedule `id`, which starts the workflow named `workflow` with `input` at each due time of `rule`, with `catchUp` deciding which missed due times run (`createLatest` uses the default, `CatchUp.Latest`).
createLatestcreateLatest handle id workflow input rule`create` with `CatchUp.Latest`, the default policy: after downtime, the schedule starts one run, for the most recent missed due time.
changechange handle id workflow input rule catchUpReplaces the schedule's workflow, input, rule and catch-up policy.
pausepause handle idStops the schedule from starting runs.
resumeresume handle idLets a paused schedule start runs again, from the first due time after the resume: due times inside the pause never run.
deletedelete handle idEnds the schedule.
statestate handle idThe schedule as the dispatcher's index knows it, or nothing when the index has not read it.

MaxIdLength

MaxIdLength
Member
The longest schedule ID, in characters: a run ID adds "@" and 28 characters of due time, the correlation IDs of a run's commands add up to 8 more, and a correlation ID holds at most 255. The persistence IDs must fit too (see `MaxPersistenceIdLength`), and Akka escapes their parts as `Uri.EscapeDataString` does, so `create` and `change` also require the escaped workflow name and the escaped schedule ID to be at most 205 characters together. A non-ASCII character escapes to 6 to 12 characters.

Returns

int

MaxPersistenceIdLength

MaxPersistenceIdLength
Member
The longest persistence ID: 255 characters, the size of the journal's column on PostgreSQL. A run journals as "<escaped workflow name>/default-shard/<escaped run ID>", which is 50 characters besides the escaped workflow name and schedule ID, and a schedule as "fcqrs-schedule/default-shard/<escaped schedule ID>".

Returns

int

register

register api runs
Member
Registers the schedule aggregate and starts this actor system's dispatcher, which may start the listed workflows. Register each workflow with `Workflows.register` first. Raises `InvalidOperationException` when the actor system has a dispatcher already, and `Akka.Configuration.ConfigurationException` when `akka.fcqrs.schedule-check-interval` is not positive. A schedule whose workflow is not listed starts no run, and the dispatcher logs an error at each of its due times, until a later start lists the workflow again. The schedule aggregate, like every aggregate, waits for the actor system's saga starters before it stores an event, and terminates the process when they are not wired within `akka.fcqrs.saga-start-timeout`. Wire them with `Fcqrs.wireSagaStarters` after registering every aggregate and saga, this one included. Until they are wired the dispatcher fires nothing, and every function of this module that sends a command raises `InvalidOperationException`. The dispatcher keeps its index in the table `fcqrs_schedule_index`, which it creates on first use in the journal's database and schema, with one row per schedule. A start reads the rows and the schedule events stored since, so it does not read the schedules' whole history again. The first start on a journal without the table reads that history once and fills the table. Raises `ArgumentException` when Akka's query journal and write journal differ in connection string, schema, table, or columns, because the table must live in the journal it reads.

Parameters

NameTypeDescription
apiIActor
runsScheduledWorkflow list

Returns

ScheduleHandle

create

create handle id workflow input rule catchUp
Member
Creates the schedule `id`, which starts the workflow named `workflow` with `input` at each due time of `rule`, with `catchUp` deciding which missed due times run (`createLatest` uses the default, `CatchUp.Latest`). Returns once the schedule is stored. Raises `ArgumentException` for a rule that `ScheduleRule.validate` rejects, a missing rule or policy, or an ID that is blank, contains '~', or is too long (see `MaxIdLength`). Raises `InvalidOperationException` when the saga starters are not wired, when the workflow is not registered with the dispatcher or takes another input, and when the schedule refuses: a schedule with this ID exists with a different content, or was deleted. A repeat with the same content is accepted and stores nothing; a weekly rule's days are sorted and their repeats removed before the comparison.

Parameters

NameTypeDescription
handleScheduleHandle
idstring
workflowstring
input'Input
ruleScheduleRule
catchUpCatchUp

Returns

Async<unit>

createLatest

createLatest handle id workflow input rule
Member
`create` with `CatchUp.Latest`, the default policy: after downtime, the schedule starts one run, for the most recent missed due time. Raises as `create` does. C#'s `CreateAsync` without a policy calls it.

Parameters

NameTypeDescription
handleScheduleHandle
idstring
workflowstring
input'Input
ruleScheduleRule

Returns

Async<unit>

change

change handle id workflow input rule catchUp
Member
Replaces the schedule's workflow, input, rule and catch-up policy. An `Every` rule counts from the change, and no due time at or before it runs. A run decided before the change starts the workflow, with the input, it was decided with. Raises `ArgumentException` and `InvalidOperationException` as `create` does, and `InvalidOperationException` when the schedule does not exist or was deleted.

Parameters

NameTypeDescription
handleScheduleHandle
idstring
workflowstring
input'Input
ruleScheduleRule
catchUpCatchUp

Returns

Async<unit>

pause

pause handle id
Member
Stops the schedule from starting runs. A run decided before the pause still starts. Raises `InvalidOperationException` when the schedule does not exist or was deleted.

Parameters

NameTypeDescription
handleScheduleHandle
idstring

Returns

Async<unit>

resume

resume handle id
Member
Lets a paused schedule start runs again, from the first due time after the resume: due times inside the pause never run. Raises `InvalidOperationException` when the schedule does not exist, was deleted, or is not paused.

Parameters

NameTypeDescription
handleScheduleHandle
idstring

Returns

Async<unit>

delete

delete handle id
Member
Ends the schedule. A run decided before the delete still starts. The ID cannot be used for a new schedule. Raises `InvalidOperationException` when the schedule does not exist.

Parameters

NameTypeDescription
handleScheduleHandle
idstring

Returns

Async<unit>

state

state handle id
Member
The schedule as the dispatcher's index knows it, or nothing when the index has not read it. A deleted schedule leaves the index once no run decided before the delete waits to start. The index lags the schedule by one projection pass, so a change that just returned may not show yet.

Parameters

NameTypeDescription
handleScheduleHandle
idstring

Returns

ScheduleView option