Skip to content

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

  1. Start creates a version-pinned run and workflowStarted.
  2. Activity completion or failure records a service-task result.
  3. User-task completion or expiry records a human decision.
  4. Signal delivery records an external event.
  5. Timer firing records that durable time elapsed.
  6. Continue as new closes the parent and creates the successor.
  7. Cancellation records a terminal decision.
  8. Recovery finds running runs 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.

See Also