Lifecycle
WorkflowRuntime has no initialize/dispose dance like WorkflowEngine. Construct it with storage and modules, then start runs. Production hosts start WorkflowServerApplication, which validates the catalog and launches the HTTP API, decider, workers, timers, heartbeats, and spawn reconciliation.
What Causes a Decision
- Start creates a version-pinned run and
workflowStarted. - Activity completion or failure records a service-task result.
- User-task completion or expiry records a human decision.
- Signal delivery records an external event.
- Timer firing records that durable time elapsed.
- Continue as new closes the parent and creates the successor.
- Cancellation records a terminal decision.
- Recovery finds
runningruns left between event and decision commit.
Every non-terminal transition invokes drive(runId).
Drive
drive reloads the run, history, and commands, verifies digest, and invokes the workflow. Replay stops at the first unresolved await, appends its command/history, and marks the run blocked.
Server Start
dart
final application = WorkflowServerApplication(
adapter: WorkflowServerAdapter(
storage: SupabaseWorkflowStorage(client: serviceRoleClient),
operations: workflowOperations,
access: accessAdapter,
),
workerId: replicaId,
observer: openTelemetryWorkflowObserver,
modules: [orders],
);
final server = await application.start(port: 8080);Registration is immutable after start(). WorkflowServerHandle.close() stops the worker and server.