Builds a typed graph. The builder issues every handle - nodes, joins - and validates the whole graph in compile, reporting every problem at once.
Nodes that route to each other in a cycle are declared first and implemented afterwards:
val b = GraphBuilder("counter", "v1")
val count = StateKey.replace[Int]("count", 0)
val tick = b.declare[Unit]("tick")
b.implement(tick, writes = Set(count)) { (_, state, _) =>
NodeResult.fromResult(state.get(count).map { n =>
val next = Command.empty.update(count, n + 1)
if n + 1 < 3 then next.goto(tick) else next
})
}
val graph = b.compile(tick)(_.get(count))
The builder is mutable and meant to be used from one thread while the graph is assembled; the CompiledGraph it produces is immutable.
Issues a handle for a node consuming I; implement it before compiling. inputVersion is the version of I's JSON shape in checkpoints, with migrations from earlier versions.
Issues a handle for a node consuming I; implement it before compiling. inputVersion is the version of I's JSON shape in checkpoints, with migrations from earlier versions.
A static edge: every completed task of from also schedules to, before the routes in its command. Edges from one node are scheduled in declaration order.
A static edge: every completed task of from also schedules to, before the routes in its command. Edges from one node are scheduled in declaration order.