Skip to content

Commit 5ad58a2

Browse files
apollo_deployments: assemble full node config via build.libsonnet
1 parent c2127ab commit 5ad58a2

1 file changed

Lines changed: 47 additions & 0 deletions

File tree

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Top-level assembler: build the per-service SequencerNodeConfig for a whole layout.
2+
//
3+
// build(layoutName, overrides) -> { [service]: <SequencerNodeConfig> }
4+
//
5+
// where `layoutName` is one of {consolidated, hybrid, distributed} and `overrides` is the object
6+
// the applicative config reads its per-environment values from (see applicative_config.libsonnet).
7+
local applicative = import 'applicative_config.libsonnet';
8+
local constants = import 'constants.libsonnet';
9+
local derive = import 'infra/derive.libsonnet';
10+
11+
local layouts = {
12+
consolidated: import 'layouts/consolidated.libsonnet',
13+
hybrid: import 'layouts/hybrid.libsonnet',
14+
distributed: import 'layouts/distributed.libsonnet',
15+
};
16+
17+
// `base_layer_config` is not a component, but is a field of SequencerNodeConfig.
18+
// It must be provided when the service runs the l1 components (L1EventsScraper and
19+
// L1GasPriceScraper).
20+
local baseLayerComponents = ['l1_events_scraper', 'l1_gas_price_scraper'];
21+
22+
// One service's applicative sections. The node requires each `<component>_config` to be set iff
23+
// that component runs within that service. The l1 components also require `base_layer_config` to be
24+
// present. All services use the same `monitoring_config`.
25+
local serviceConfig(applicativeConfig, runs) =
26+
{
27+
[component + '_config']: applicativeConfig[component + '_config']
28+
for component in runs
29+
if std.objectHas(applicativeConfig, component + '_config')
30+
}
31+
+ (if std.length(std.setInter(std.set(runs), std.set(baseLayerComponents))) > 0
32+
then { base_layer_config: applicativeConfig.base_layer_config }
33+
else {})
34+
+ { monitoring_config: applicativeConfig.monitoring_config };
35+
36+
{
37+
build(layoutName, overrides)::
38+
assert std.objectHas(layouts, layoutName) : 'unknown layout: %s' % layoutName;
39+
local layout = layouts[layoutName];
40+
local applicativeConfig = applicative(overrides);
41+
{
42+
[service]: serviceConfig(applicativeConfig, layout.services[service].runs)
43+
+ { components: derive.componentsFor(layout, service) }
44+
+ { validation_only: std.get(overrides, 'validation_only', constants.DEFAULT_VALIDATION_ONLY) }
45+
for service in std.objectFields(layout.services)
46+
},
47+
}

0 commit comments

Comments
 (0)