-
Notifications
You must be signed in to change notification settings - Fork 0
How To Execute Multiple Routes with MultiPipe
Fernando Koch edited this page Mar 30, 2026
·
2 revisions
Use MultiPipe when all matching branches should execute instead of selecting only one.
This is the GraphK tool for fan-out behavior across multiple matching routes.
graphk.MultiPipe extends BranchPipe, but instead of choosing one matching branch, it:
- resolves all matching branch indices
- orders the selected matches
- executes every selected branch in that order
Good use cases:
- run several matching handlers
- apply multiple route-specific transformations
- execute parallel-in-concept branches sequentially in one pipeline
- fan out work to all matching route groups
Use MultiPipe when many routes should run.
Use BranchPipe when only one route should run.
Important constants:
MultiPipe.ORDER_STOREDMultiPipe.ORDER_RANDOM
Use when:
- execution should follow branch definition order
- behavior should remain deterministic
Use when:
- execution order can vary intentionally
- or when randomness is seeded for controlled demonstration
import graphk
pipe = graphk.MultiPipe(
order_policy=graphk.MultiPipe.ORDER_STORED,
nodes=[
(
graphk.Matcher(task="route"),
graphk.SequencePipe(nodes=[graphk.demo.RouteNode("A")]),
),
(
graphk.Matcher(task="route"),
graphk.SequencePipe(nodes=[graphk.demo.RouteNode("B")]),
),
],
)
pipeline = graphk.SequencePipe(nodes=[pipe])
session = graphk.Session(task="route")
runner = graphk.Runner(pipeline, session)
runner.start()
runner.run()
print(session.to_dict())Apply all matching route handlers to a single request.
Run several transformations in a defined order but still model them as separate branches.
Model several optional workflows that should all run when their matchers pass.
Use BranchPipe when:
- one route should win
- routing is exclusive
Use MultiPipe when:
- every matching route should run
- routing is cumulative
- Do not use
MultiPipewhen only one route is supposed to execute. - Do not assume
ORDER_RANDOMis stable unless randomness is explicitly seeded. - Do not forget that each selected item is still expected to be a pipeline branch.
Recommended references: