Flow Basics
A Flow is the top-level component that you register with Dex.
It defines the Steps that run in the background, the Attributes and Channels that persist state, and the RPCs that provide durable communication.
Implement a Flow
You define a Flow by implementing the Flow interface.
Most SDKs derive FlowType from the struct/class type name unless you override it.
A Flow implementation mainly contains:
- Steps — the start Step and other Steps the Flow runs.
- Persistence schema — the Attribute and Channel the Flow reads or writes.
- RPC handlers — methods that the Flow may invoke.
status = Attribute("status", str)
notify = Channel("notify", None)
class ExampleFlow(Flow[int]):
def __init__(self) -> None:
self.finish = FinishStep()
self.example = ExampleStep(self.finish)
def get_steps(self) -> StepList[int]:
return StepList.start_step(self.example).other_steps(self.finish)
def get_persistence_schema(self) -> PersistenceSchema:
return PersistenceSchema.of(status, notify)
@rpc
def describe(self, context: Context) -> RPCResult[str]:
return RPCResult.of(status.get(context))
Example: examples/python/dex_examples/primitives/flow/example_flow.py
Identifiers
Dex uses these identifiers throughout its APIs and documentation.
First, when mentioning Flow, depending on the context, it usually means a Flow definition identified by its FlowType, or a Flow execution identified by its Flow ID.
| Identifier | Who sets it | Meaning |
|---|---|---|
| FlowType | Application (via Flow implementation) | Stable type name Dex uses to route Worker calls and search results. |
| Flow ID | Application client on start | Business identity for one Flow execution. ID reuse policy controls whether another Flow execution may start with the same Flow ID. |
| Run ID | Dex Server | Identity of one backend run attempt. Time travel and continue-as-new assign a fresh Run ID while keeping the same Flow execution. |
| StepType | Application (via Step implementation) | Stable name for a Step definition inside the Flow. |
| StepExecutionID | Dex Server | One execution instance of a Step type, formatted as StepType-Number. |
Steps
GetSteps / get_steps / steps registers one start Step and every other Step type the Flow may reach through StepDecision movements. The start Step input type is also the Flow start input.
An empty Step list, or a list with no start Step, is valid when the Flow is driven entirely by RPCs that later move into Steps.
See Step basics for WaitFor, Execute, and default Step options.
Persistence schema
The persistence schema lists every Attribute and Channel used from Steps or RPCs. Dex rejects reads and writes to names that are not declared.
RPC handlers
Dex registers RPC methods under their method names (or explicit RPC names in Rust). Clients call them with InvokeRPC; Dex then dispatches the call to the Worker.