TaskGraph

data class TaskGraph(val id: String, val nodes: List<TaskRequest>, val edges: List<TaskGraph.Edge>)

A directed acyclic graph (DAG) of tasks with dependency edges.

Unlike TaskChain (sequential), a TaskGraph allows parallel execution of independent tasks that converge at join points.

kmpWorker.graph("pipeline") {
val fetch = task("fetch-data")
val process = task("process")
val validate = task("validate")
val upload = task("upload")

fetch then process // process depends on fetch
fetch then validate // validate runs in parallel with process
process then upload // upload waits for BOTH
validate then upload
}

Constructors

Link copied to clipboard
constructor(id: String, nodes: List<TaskRequest>, edges: List<TaskGraph.Edge>)

Types

Link copied to clipboard
data class Edge(val from: String, val to: String)

Properties

Link copied to clipboard
Link copied to clipboard
val id: String
Link copied to clipboard
Link copied to clipboard

Task IDs with no incoming edges — these start first.

Functions

Link copied to clipboard

Returns all task IDs that taskId depends on.

Link copied to clipboard
fun dependentsOf(taskId: String): Set<String>

Returns all task IDs that depend on taskId.