enqueueGraph method

  1. @override
Future<GraphExecution> enqueueGraph(
  1. TaskGraph graph
)
override

Schedule a TaskGraph (directed acyclic graph) of background tasks.

Implementation

@override
Future<GraphExecution> enqueueGraph(TaskGraph graph) async {
  graph.validate();

  // Record root nodes as enqueued (since they start immediately)
  final rootNodes = graph.nodes.where((n) => n.dependsOn.isEmpty);
  for (final node in rootNodes) {
    enqueued.add(EnqueueCall(
      taskId: node.id,
      trigger: const TaskTrigger.oneTime(),
      worker: node.worker,
      constraints: node.constraints,
      existingPolicy: ExistingTaskPolicy.replace,
      tag: null,
    ));
  }

  // In a fake, we don't actually run the DAG logic unless requested.
  // For now just return a handle that never completes automatically.
  return GraphExecution.internal(graph.id, Completer<GraphResult>().future);
}