Skip to main content

Iteration

IterationFlow migrates a large collection one page at a time. IterationStep reads and processes the page, then passes the next page token as the input of its next execution. When there is no token, the Flow completes. This is structurally similar to timer polling, but the loop carries pagination state.

Definition graph

IterationFlow

Valid

python · examples/python/dex_examples/patterns/polling/iteration_flow.py

Core implementation

class IterationStep(Step[str]):
def execute(self, context: Context, page_token: str) -> StepDecision:
next_page_token = (
"page-2"
if not page_token
else "page-3"
if page_token == "page-2"
else ""
)
if not next_page_token:
return graceful_complete()
return go_to(IterationStep, next_page_token)

Example: examples/python/dex_examples/patterns/polling/iteration_flow.py