Expand description
Workflow-task dispatch endpoints (Phase 9).
A “workflow task” represents “this workflow has new events that need a worker to run the workflow handler against.” It’s distinct from an “activity task” (which runs concrete activity code). The dispatch loop:
- The engine sets
needs_dispatch=trueon a workflow when something workflow-visible happens (started, activity completed, timer fired, signal arrived). - A worker calls
POST /workflow-tasks/pollto claim the next dispatchable workflow on its queue. Response carries the workflow id, type, input, and full event history for replay. - The worker invokes the handler in a coroutine that yields commands (ScheduleActivity, CompleteWorkflow, FailWorkflow, etc.) instead of making side effects directly.
- The worker
POST /workflow-tasks/:id/commandsto submit the batch. The engine processes each command transactionally and releases the worker’s claim on the workflow task.
Structs§
Functions§
- poll_
workflow_ task - Claim a dispatchable workflow on the requested queue. Response is
nullwhen nothing is available (worker should sleep + retry). - router
- submit_
commands - Submit a batch of commands a worker produced from running the workflow handler. Each command is processed transactionally (ScheduleActivity inserts a row + appends ActivityScheduled, CompleteWorkflow flips the status + appends WorkflowCompleted, etc.) and the worker’s claim is released on success.