Skip to content

Commit d26c932

Browse files
committed
ArC: introduce quarkus.arc.dev-mode.generate-dependency-graphs=auto
- and use it as a default value
1 parent fce38ed commit d26c932

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcDevModeConfig.java

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,17 @@ public interface ArcDevModeConfig {
1515
boolean monitoringEnabled();
1616

1717
/**
18-
* If set to true then the dependency graphs are generated and available in the Dev UI.
18+
* If set to {@code true} then the dependency graphs are generated and available in the Dev UI. If set to {@code auto}
19+
* then the dependency graphs are generated if there's less than 1000 beans in the application. If set to {@code false} the
20+
* dependency graphs are not generated.
1921
*/
20-
@WithDefault("true")
21-
boolean generateDependencyGraphs();
22+
@WithDefault("auto")
23+
GenerateDependencyGraphs generateDependencyGraphs();
24+
25+
public enum GenerateDependencyGraphs {
26+
TRUE,
27+
FALSE,
28+
AUTO
29+
}
2230

2331
}

extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/devui/ArcDevModeApiProcessor.java

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,16 @@ public class ArcDevModeApiProcessor {
3333

3434
private static final Logger LOG = Logger.getLogger(ArcDevModeApiProcessor.class);
3535

36+
/**
37+
* Do not generate dependency graphs for apps with more than N beans
38+
*/
39+
private static final int DEPENCENY_GRAPH_BEANS_LIMIT = 1000;
40+
3641
/**
3742
* If a dependency graph exceeds the limit then we apply the {@link DevBeanInfos#MAX_DEPENDENCY_LEVEL} and if still exceeds
3843
* the limit it's skipped completely, i.e. dependency graph is not available
3944
*/
40-
private static final int DEPENCENY_GRAPH_LIMIT = 30;
45+
private static final int DEPENCENY_GRAPH_NODES_LIMIT = 30;
4146

4247
@BuildStep(onlyIf = IsDevelopment.class)
4348
public void collectBeanInfo(ArcConfig config, ValidationPhaseBuildItem validationPhaseBuildItem,
@@ -75,7 +80,7 @@ public void collectBeanInfo(ArcConfig config, ValidationPhaseBuildItem validatio
7580

7681
// Build dependency graphs
7782
Map<String, List<String>> beanDependenciesMap = new HashMap<>();
78-
if (config.devMode().generateDependencyGraphs()) {
83+
if (generateDependencyGraphs(config, beanInfos)) {
7984
BeanResolver resolver = validationPhaseBuildItem.getBeanResolver();
8085
Collection<BeanInfo> beans = validationContext.get(BuildExtension.Key.BEANS);
8186
Map<BeanInfo, List<InjectionPointInfo>> directDependents = new HashMap<>();
@@ -99,9 +104,9 @@ public void collectBeanInfo(ArcConfig config, ValidationPhaseBuildItem validatio
99104
// Skip the graph if no links exist
100105
continue;
101106
}
102-
if (dependencyGraph.nodes.size() > DEPENCENY_GRAPH_LIMIT) {
107+
if (dependencyGraph.nodes.size() > DEPENCENY_GRAPH_NODES_LIMIT) {
103108
DependencyGraph visibleGraph = dependencyGraph.forLevel(DevBeanInfos.DEFAULT_MAX_DEPENDENCY_LEVEL);
104-
if (visibleGraph.nodes.size() > DEPENCENY_GRAPH_LIMIT) {
109+
if (visibleGraph.nodes.size() > DEPENCENY_GRAPH_NODES_LIMIT) {
105110
LOG.debugf("Skip dependency graph for %s - too many visible nodes: %s", bean,
106111
visibleGraph.nodes.size());
107112
continue;
@@ -210,4 +215,13 @@ private void addNodesDependents(int level, BeanInfo root, Set<DevBeanInfo> nodes
210215
}
211216
}
212217

218+
private boolean generateDependencyGraphs(ArcConfig config, DevBeanInfos beanInfos) {
219+
return switch (config.devMode().generateDependencyGraphs()) {
220+
case TRUE -> true;
221+
case FALSE -> false;
222+
case AUTO -> beanInfos.getBeans().size() < DEPENCENY_GRAPH_BEANS_LIMIT;
223+
default -> throw new IllegalArgumentException("Unexpected value: " + config.devMode().generateDependencyGraphs());
224+
};
225+
}
226+
213227
}

0 commit comments

Comments
 (0)