dvAdminGraphQueues function

List<String> dvAdminGraphQueues(
  1. String root
)

The queues the project graph in root names: every @DVJob's queue.

The build writes the graph beside Studio, and it is the one place a server knows its queue names from. Read on each request, so a graph that is missing or unreadable lists no queue of its own rather than failing.

Implementation

List<String> dvAdminGraphQueues(String root) {
  final File graph = File('$root${Platform.pathSeparator}graph.json');
  try {
    final Object? decoded = jsonDecode(graph.readAsStringSync());
    final Object? jobs = decoded is Map ? decoded['jobs'] : null;
    return <String>{
      if (jobs is List)
        for (final Object? job in jobs)
          if (job is Map && job['queue'] is String && '${job['queue']}'.isNotEmpty)
            '${job['queue']}',
    }.toList();
  } on Object {
    return const <String>[];
  }
}