Module concurrency
Expand description
Runs at once per type or key: at most limit runs of a workflow type (or
of one key of it, a tenant say) run at a time; the others wait, in the
order they were started, and show as queued.
Built from runs, so a turn is kept while its run is parked and across crashes, and nothing of it touches a step:
- A start of a limited type starts a slot instead,
fusee.queued/<id>, whose input names the type, ID and input. - The slot starts the type’s (or key’s) coordinator,
fusee.concurrency/<type>[/<key>], attaching to it if it runs, and asks it for a turn (a signal). - The coordinator keeps the queue and the runs holding a turn in its
journal, admits runs in the order they asked while fewer than
limithold one (a signal back), and continues as new now and then with that state. - An admitted slot runs the workflow under its own ID as a child, gives the turn back when it ends however it ends, and returns its result.
result(id) follows the slot until the run exists (as for a delayed
start). Cancelling a slot that waits takes its request back; terminate
the run, not its slot, once it runs (a terminated slot keeps its turn).
Structs§
- Queued
- A slot’s input: the run to start once admitted.
- Turns
- The coordinator’s state, carried across continue-as-new.
Constants§
- COORDINATOR_
TYPE - The coordinator’s workflow type.
- SLOT_
TYPE - The slot’s workflow type.
Functions§
- coordinator_
id - The coordinator’s workflow ID for a type, and a key if the limit is per key.
- slot_id
- The slot’s workflow ID for a run’s ID.