@yarkivaev/scada 2.28.0 → 2.29.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -2
- package/package.json +1 -1
- package/src/application/deploy/collectionEvents.js +49 -0
- package/src/application/deploy/collectionPlacement.js +42 -0
- package/src/application/deploy/compileLocalConsumers.js +34 -0
- package/src/application/deploy/expand.js +1 -0
- package/src/application/deploy/mergeDocuments.js +9 -1
- package/src/application/deploy/namedCollection.js +110 -21
- package/src/application/deploy/namedProcessing.js +86 -0
- package/src/application/deploy/normalizeControlPlane.js +43 -0
- package/src/application/deploy/projectCollectionRoutes.js +20 -18
- package/src/application/deploy/projectControlPlane.js +2 -2
- package/src/application/deploy/readDeploymentDocument.js +5 -1
- package/src/application/plantServer.js +1 -0
- package/src/application/siteServer.js +1 -0
- package/src/infrastructure/catalog/tagCatalog.js +4 -3
- package/src/infrastructure/deploy/centralTelemetry.js +10 -1
- package/src/infrastructure/deploy/collectorChartPlan.js +1 -1
- package/src/infrastructure/deploy/configuredBundleCapabilities.js +1 -1
- package/src/infrastructure/deploy/index.js +3 -2
- package/src/infrastructure/opcua/projectSources.js +3 -3
package/README.md
CHANGED
|
@@ -44,9 +44,11 @@ The release workflow publishes Node.js and JVM images and records their digests
|
|
|
44
44
|
|
|
45
45
|
## Collection deployment DSL
|
|
46
46
|
|
|
47
|
-
A deployment document can declare equipment endpoints in `sources`, logical inputs in `streams`, and assignment policy in `controlPlane.readers`. Each reader refers to one stream through its key or to a list under `streams`. Its ordered `eligible` nodes and requested `copies` guide the controller.
|
|
47
|
+
A deployment document can declare equipment endpoints in `sources`, logical inputs in `streams`, and assignment policy in `controlPlane.readers`. Each reader refers to one stream through its key or to a list under `streams`. Its ordered `eligible` nodes and requested `copies` guide the controller. A source address can be a `$secret` reference that the executing adapter resolves. Push sources declare their API and event type through a stream.
|
|
48
48
|
|
|
49
|
-
`
|
|
49
|
+
`delivery` can group streams and processing outputs with the same destination under a `streams` list and a `to` target. It derives senders from reader or workload placement. A `$ref: localState` target uses the machine's home from `controlPlane.localState.placements`. Archive destinations may receive data without participating in reads.
|
|
50
|
+
|
|
51
|
+
`readDeploymentDocument` loads `controlPlane.fragments` and machine type processing profiles relative to the root document. It rejects duplicate control-plane keys across fragments. `resolveCollection` resolves inputs and delivery references. `compileNamedControlCatalog` combines placement with application adapter specifications. `bindControlInstallation` joins topology with installation settings and agent options from server profiles. The default node scheduling capacity is 100.
|
|
50
52
|
|
|
51
53
|
## Package boundary
|
|
52
54
|
|
package/package.json
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { localOwner } from './collectionPlacement.js';
|
|
2
|
+
|
|
3
|
+
function eventRoute({ id, type, node, machine, api }, route, owners) {
|
|
4
|
+
const home = route.localState && localOwner(owners, machine);
|
|
5
|
+
const to = home && !route.to.includes(home) ? [...route.to, home] : route.to;
|
|
6
|
+
const viaApi = route.viaApi ?? api;
|
|
7
|
+
return { id, type, node, machine, to, ...(viaApi && { viaApi }) };
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
function pushRoutes(stream, route, machines, owners, servers) {
|
|
11
|
+
const { api } = stream.source;
|
|
12
|
+
const assigned = stream.path ? [stream.path] : [...machines.keys()];
|
|
13
|
+
return assigned.flatMap((machine) => {
|
|
14
|
+
const node = localOwner(owners, machine) ?? machines.get(machine);
|
|
15
|
+
if (!node || (api && !servers.get(node)?.api?.some(({ id }) => { return id === api; }))) { return []; }
|
|
16
|
+
return [eventRoute({ id: stream.output ?? stream.id, type: stream.type, node, machine, api }, route, owners)];
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function readerEvents(readers, deliverable, delivery, owners) {
|
|
21
|
+
return readers.filter(({ output }) => { return output !== undefined; }).flatMap((reader) => {
|
|
22
|
+
const { output, eligible, streams } = reader;
|
|
23
|
+
const type = deliverable.get(output)?.type;
|
|
24
|
+
if (!type) { throw new TypeError(`Unknown event output ${output} for reader ${reader.id}`); }
|
|
25
|
+
if (!Object.hasOwn(delivery, output)) { return []; }
|
|
26
|
+
return streams.flatMap(({ path }) => {
|
|
27
|
+
return eligible.map((node) => { return eventRoute({ id: output, type, node, machine: path }, delivery[output], owners); });
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function eventRoutes({ document, streams, outputs, delivery, owners, workloads }) {
|
|
33
|
+
const machines = new Map(Object.entries(owners));
|
|
34
|
+
for (const { assignments } of Object.values(workloads)) {
|
|
35
|
+
for (const { machines: selected, nodes: [primary] } of assignments) {
|
|
36
|
+
selected.forEach(({ path }) => { if (!machines.has(path)) { machines.set(path, primary); } });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
const servers = new Map(document.servers?.map((server) => { return [server.id, server]; }));
|
|
40
|
+
const processing = Object.entries(outputs).filter(([id]) => { return Object.hasOwn(delivery, id); }).flatMap(([id, { type, producers }]) => {
|
|
41
|
+
return producers.flatMap(({ machine, nodes }) => {
|
|
42
|
+
return nodes.map((node) => { return eventRoute({ id, type, node, machine }, delivery[id], owners); });
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
const pushed = [...streams.values()].filter(({ source, output, id }) => {
|
|
46
|
+
return source.mode === 'push' && Object.hasOwn(delivery, output ?? id);
|
|
47
|
+
}).flatMap((stream) => { return pushRoutes(stream, delivery[stream.output ?? stream.id], machines, owners, servers); });
|
|
48
|
+
return [...processing, ...pushed];
|
|
49
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { treePaths } from './expandNamespace.js';
|
|
2
|
+
|
|
3
|
+
function machinePath(paths, machine) {
|
|
4
|
+
const matches = paths.filter((path) => { return path === machine || path.split('/').at(-1) === machine; });
|
|
5
|
+
if (matches.length !== 1) { throw new TypeError(`Invalid local state machine ${machine}`); }
|
|
6
|
+
return matches[0];
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function placementEntries(placements) {
|
|
10
|
+
if (!placements || typeof placements !== 'object' || Array.isArray(placements)) {
|
|
11
|
+
throw new TypeError('Local state placements must be a map');
|
|
12
|
+
}
|
|
13
|
+
return Object.entries(placements);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function placementMap(document, servers) {
|
|
17
|
+
const placements = document.controlPlane?.localState?.placements;
|
|
18
|
+
if (placements === undefined) { return document.objectOwners ?? {}; }
|
|
19
|
+
const paths = treePaths(document.namespace);
|
|
20
|
+
const owners = new Map(Object.entries(document.objectOwners ?? {}));
|
|
21
|
+
for (const [node, machines] of placementEntries(placements)) {
|
|
22
|
+
if (!servers.has(node) || !Array.isArray(machines) || machines.length === 0) {
|
|
23
|
+
throw new TypeError(`Invalid local state placement on ${node}`);
|
|
24
|
+
}
|
|
25
|
+
for (const machine of machines) {
|
|
26
|
+
const path = machinePath(paths, machine);
|
|
27
|
+
if (owners.has(path)) { throw new TypeError(`Duplicate local state machine ${machine}`); }
|
|
28
|
+
owners.set(path, node);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return Object.fromEntries(owners);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export function localOwner(owners, path) {
|
|
35
|
+
if (path === undefined) { return undefined; }
|
|
36
|
+
return Object.entries(owners).filter(([prefix]) => { return path === prefix || path.startsWith(`${prefix}/`); })
|
|
37
|
+
.sort(([left], [right]) => { return right.length - left.length; })[0]?.[1];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function localStateReference(value) {
|
|
41
|
+
return value?.$ref === 'localState' && Object.keys(value).length === 1;
|
|
42
|
+
}
|
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
import { collectorConsumerTasks } from './collectorSourcePlan.js';
|
|
2
2
|
import deploymentTemplate from '../../infrastructure/deploy/deploymentTemplate.js';
|
|
3
|
+
import { resolveCollection } from './namedCollection.js';
|
|
4
|
+
|
|
5
|
+
const batchOptions = { size: 50, interval: 2, threshold: 5, timeout: 60 };
|
|
6
|
+
const postgres = { $secret: 'POSTGRES_URL' };
|
|
7
|
+
const amqp = { $secret: 'AMQP_URL' };
|
|
8
|
+
|
|
9
|
+
function localReceivers(node, { routes, topics, devices, clientId, localState, preferences }) {
|
|
10
|
+
const { operations, telemetry, stomp } = preferences;
|
|
11
|
+
function localEvents(event) { return routes[event]?.localState || routes[event]?.to.includes(node); }
|
|
12
|
+
return [
|
|
13
|
+
topics.length && { id: 'mqtt', spec: { adapter: 'mqtt-pg-metrics', mqtt: { $secret: 'MQTT_URL' },
|
|
14
|
+
postgres, devices, topic: topics.join(','), firstWins: true, options: { ...batchOptions, clientId } } },
|
|
15
|
+
localEvents('operations') && operations?.enabled !== false && { id: 'operations', spec: { adapter: 'operation-sync', amqp,
|
|
16
|
+
postgres, queue: operations?.queue ?? 'scada.operations.from-sensors', options: batchOptions } },
|
|
17
|
+
['segments', 'alerts', 'user_decisions'].some(localEvents) && { id: 'stomp', spec: { adapter: 'stomp-ingest',
|
|
18
|
+
stomp: { $secret: 'STOMP_URL' }, postgres, config: { ...batchOptions, ...localState,
|
|
19
|
+
prefetch: 128, repairHistoryOnStart: false, deadLetter: false, ...stomp } } },
|
|
20
|
+
topics.length && telemetry?.enabled !== false && { id: 'amqp-metrics', spec: { adapter: 'amqp-pg-metrics', amqp,
|
|
21
|
+
postgres, devices, queue: telemetry?.queue ?? 'scada.telemetry.ingest', firstWins: true, options: batchOptions } }
|
|
22
|
+
].filter(Boolean);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Build the ingress assignments for state owned by one node using collection and delivery. */
|
|
26
|
+
export function namedLocalConsumers(document, node, { generation = 1, wire, preferences = {} }) {
|
|
27
|
+
const { objectOwners, delivery, readers } = resolveCollection(document);
|
|
28
|
+
const paths = Object.keys(objectOwners).filter((path) => { return objectOwners[path] === node; });
|
|
29
|
+
if (!paths.length || wire === undefined) { return []; }
|
|
30
|
+
const targets = readers.flatMap(({ streams }) => { return streams; }).filter(({ id, path }) => {
|
|
31
|
+
return delivery[id]?.to.includes(node) && paths.some((home) => { return path === home || path.startsWith(`${home}/`); });
|
|
32
|
+
});
|
|
33
|
+
const configuration = wire(paths, targets);
|
|
34
|
+
return collectorConsumerTasks(localReceivers(node, { ...configuration, routes: delivery, preferences,
|
|
35
|
+
localState: document.controlPlane.history?.sink?.segmentPolicy }), node, {}, generation);
|
|
36
|
+
}
|
|
3
37
|
|
|
4
38
|
function ownedPath(document, prefix, cluster) {
|
|
5
39
|
const paths = Object.entries(document.objectOwners ?? {}).filter(([path, owner]) => {
|
|
@@ -45,6 +45,7 @@ export default function expand(document) {
|
|
|
45
45
|
const servers = expandServers(input.servers || [], paths, input.mappings || {});
|
|
46
46
|
return frozen({
|
|
47
47
|
...(input.hmi !== undefined && { hmi: input.hmi }),
|
|
48
|
+
...(input.eventDelivery !== undefined && { eventDelivery: input.eventDelivery }),
|
|
48
49
|
mappings: input.mappings || {},
|
|
49
50
|
namespace,
|
|
50
51
|
profiles,
|
|
@@ -68,6 +68,13 @@ function mergeNodes(left, right) {
|
|
|
68
68
|
return Array.from(value.values());
|
|
69
69
|
}
|
|
70
70
|
|
|
71
|
+
function mergeDelivery(left, right) {
|
|
72
|
+
if (!Array.isArray(left) && !Array.isArray(right)) { return mergeMaps(left, right); }
|
|
73
|
+
const groups = [left, right].filter((value) => { return value !== undefined; });
|
|
74
|
+
if (!groups.every(Array.isArray)) { throw new TypeError('Cannot mix delivery lists and maps'); }
|
|
75
|
+
return groups.flat();
|
|
76
|
+
}
|
|
77
|
+
|
|
71
78
|
/**
|
|
72
79
|
* Overlays one system document on another.
|
|
73
80
|
*
|
|
@@ -88,9 +95,10 @@ export default function mergeDocuments(base, extra) {
|
|
|
88
95
|
if (base.mappings || extra.mappings) {
|
|
89
96
|
document.mappings = mergeMaps(base.mappings, extra.mappings);
|
|
90
97
|
}
|
|
91
|
-
for (const key of ['sources', 'streams', '
|
|
98
|
+
for (const key of ['sources', 'streams', 'objectOwners', 'externalPublications', 'routes', 'machineTypes']) {
|
|
92
99
|
if (base[key] || extra[key]) { document[key] = mergeMaps(base[key], extra[key]); }
|
|
93
100
|
}
|
|
101
|
+
if (base.delivery || extra.delivery) { document.delivery = mergeDelivery(base.delivery, extra.delivery); }
|
|
94
102
|
if (base.profiles || extra.profiles) {
|
|
95
103
|
document.profiles = mergeMaps(base.profiles, extra.profiles);
|
|
96
104
|
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { sourceAddress } from './deploymentRouting.js';
|
|
2
|
+
import { processingOutputs, resolveWorkloads } from './namedProcessing.js';
|
|
3
|
+
import { eventRoutes, readerEvents } from './collectionEvents.js';
|
|
4
|
+
import { localOwner, localStateReference, placementMap } from './collectionPlacement.js';
|
|
2
5
|
|
|
3
6
|
function asMap(value, label) {
|
|
4
7
|
if (!value || typeof value !== 'object' || Array.isArray(value)) { throw new TypeError(`${label} must be a map`); }
|
|
@@ -14,9 +17,10 @@ function ids(value, label, known) {
|
|
|
14
17
|
return list;
|
|
15
18
|
}
|
|
16
19
|
|
|
17
|
-
function
|
|
18
|
-
const { source, path, query, mapping } =
|
|
19
|
-
const
|
|
20
|
+
function pullStream(id, declaration, sources, mappings) {
|
|
21
|
+
const { source, path, query, mapping } = declaration;
|
|
22
|
+
const input = sources[source];
|
|
23
|
+
const { address } = input;
|
|
20
24
|
if (typeof path !== 'string' || path.split('/').some((part) => { return !part; })) {
|
|
21
25
|
throw new TypeError(`Invalid path for stream ${id}`);
|
|
22
26
|
}
|
|
@@ -24,24 +28,47 @@ function resolveStream(id, declaration, sources, mappings) {
|
|
|
24
28
|
throw new TypeError(`Unknown mapping ${mapping} for stream ${id}`);
|
|
25
29
|
}
|
|
26
30
|
const resolvedMapping = typeof mapping === 'string' ? mappings[mapping] : mapping;
|
|
27
|
-
|
|
31
|
+
const secret = address && typeof address === 'object' && Object.keys(address).length === 1
|
|
32
|
+
&& typeof address.$secret === 'string' && address.$secret;
|
|
33
|
+
if (secret && query !== undefined) { throw new TypeError(`Source ${source} cannot add query parameters to a secret address`); }
|
|
34
|
+
return { ...declaration, id, source: input, address, from: secret ? address : sourceAddress(sources, source, query), path, name: path, resolvedMapping };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function resolveStream(id, declaration, sources, mappings) {
|
|
38
|
+
const { source, type, query } = asMap(declaration, `Stream ${id}`);
|
|
39
|
+
if (typeof source !== 'string' || !Object.hasOwn(sources ?? {}, source)) { throw new TypeError(`Unknown source ${source}`); }
|
|
40
|
+
const input = asMap(sources[source], `Source ${source}`);
|
|
41
|
+
if (input.mode !== 'push') { return pullStream(id, declaration, sources, mappings); }
|
|
42
|
+
if (typeof type !== 'string' || !type || query !== undefined) { throw new TypeError(`Invalid push stream ${id}`); }
|
|
43
|
+
return { ...declaration, id, source: input };
|
|
28
44
|
}
|
|
29
45
|
|
|
30
|
-
function
|
|
46
|
+
function readerNodes(id, eligible, reading, controlNodes, owners) {
|
|
47
|
+
const list = Array.isArray(eligible) ? eligible : [eligible];
|
|
48
|
+
return ids(list.map((node) => {
|
|
49
|
+
if (!localStateReference(node)) { return node; }
|
|
50
|
+
const homes = new Set(reading.map(({ path }) => { return localOwner(owners, path); }));
|
|
51
|
+
if (homes.size !== 1 || homes.has(undefined)) { throw new TypeError(`Reader ${id} requires one local state placement`); }
|
|
52
|
+
return [...homes][0];
|
|
53
|
+
}), `eligible nodes for reader ${id}`, controlNodes);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolveReaders(declarations, streams, controlNodes, owners) {
|
|
31
57
|
const readers = [];
|
|
32
58
|
const assigned = new Set();
|
|
33
59
|
for (const [id, declaration] of Object.entries(asMap(declarations, 'Control readers'))) {
|
|
34
|
-
const { streams: included = [id], eligible, copies = 1, cost = 1 } = asMap(declaration, `Reader ${id}`);
|
|
35
|
-
const nodes = ids(eligible, `eligible nodes for reader ${id}`, controlNodes);
|
|
36
|
-
if (!Number.isSafeInteger(copies) || copies < 1 || copies > nodes.length || !Number.isSafeInteger(cost) || cost < 1) {
|
|
37
|
-
throw new TypeError(`Invalid copies or cost for reader ${id}`);
|
|
38
|
-
}
|
|
60
|
+
const { streams: included = [id], eligible, copies = 1, cost = 1, adapter, output } = asMap(declaration, `Reader ${id}`);
|
|
39
61
|
const reading = ids(included, `streams for reader ${id}`, streams).map((stream) => {
|
|
40
62
|
if (assigned.has(stream)) { throw new TypeError(`Stream ${stream} has more than one reader`); }
|
|
41
63
|
assigned.add(stream);
|
|
42
64
|
return streams.get(stream);
|
|
43
65
|
});
|
|
44
|
-
|
|
66
|
+
const nodes = readerNodes(id, eligible, reading, controlNodes, owners);
|
|
67
|
+
if (!Number.isSafeInteger(copies) || copies < 1 || copies > nodes.length || !Number.isSafeInteger(cost) || cost < 1) {
|
|
68
|
+
throw new TypeError(`Invalid copies or cost for reader ${id}`);
|
|
69
|
+
}
|
|
70
|
+
readers.push({ id, eligible: nodes, copies, cost, streams: reading,
|
|
71
|
+
...(adapter !== undefined && { adapter }), ...(output !== undefined && { output }) });
|
|
45
72
|
}
|
|
46
73
|
for (const id of streams.keys()) {
|
|
47
74
|
if (!assigned.has(id)) { throw new TypeError(`Stream ${id} has no reader`); }
|
|
@@ -49,20 +76,82 @@ function resolveReaders(declarations, streams, controlNodes) {
|
|
|
49
76
|
return readers;
|
|
50
77
|
}
|
|
51
78
|
|
|
79
|
+
function routeEntries(delivery, known) {
|
|
80
|
+
if (!Array.isArray(delivery)) { return Object.entries(asMap(delivery, 'Delivery')); }
|
|
81
|
+
return delivery.flatMap((route) => {
|
|
82
|
+
return ids(asMap(route, 'Delivery group').streams, 'streams in delivery group', known).map((stream) => {
|
|
83
|
+
return [stream, route];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function routeDestinations(id, route, stream, servers, owners) {
|
|
89
|
+
const { to, viaApi } = asMap(route, `Delivery ${id}`);
|
|
90
|
+
if (Object.hasOwn(route, 'from')) { throw new TypeError(`Delivery ${id} cannot declare from`); }
|
|
91
|
+
if (viaApi !== undefined && (typeof viaApi !== 'string' || !viaApi)) { throw new TypeError(`Invalid delivery API for ${id}`); }
|
|
92
|
+
const targets = Array.isArray(to) ? to : [to];
|
|
93
|
+
const local = targets.some(localStateReference);
|
|
94
|
+
const dynamic = local && stream.path === undefined;
|
|
95
|
+
const home = localOwner(owners, stream.path);
|
|
96
|
+
const resolved = targets.filter((target) => { return !localStateReference(target); });
|
|
97
|
+
if (local && home !== undefined && !resolved.includes(home)) { resolved.push(home); }
|
|
98
|
+
if (!dynamic || resolved.length > 0) { ids(resolved, `destinations for stream ${id}`, servers); }
|
|
99
|
+
return { to: resolved, viaApi, ...(dynamic && { localState: true }) };
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function routes(delivery, streams, servers, owners) {
|
|
103
|
+
const destinations = new Map();
|
|
104
|
+
for (const [id, route] of routeEntries(delivery, streams)) {
|
|
105
|
+
const stream = streams.get(id);
|
|
106
|
+
if (!stream) { throw new TypeError(`Unknown delivery stream ${id}`); }
|
|
107
|
+
if (destinations.has(id)) { throw new TypeError(`Stream ${id} has more than one delivery declaration`); }
|
|
108
|
+
destinations.set(id, routeDestinations(id, route, stream, servers, owners));
|
|
109
|
+
}
|
|
110
|
+
return Object.fromEntries(destinations);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
function outputStreams(streams, outputs) {
|
|
114
|
+
const deliverable = new Map(streams);
|
|
115
|
+
for (const [id, output] of Object.entries(outputs)) {
|
|
116
|
+
if (deliverable.has(id)) { throw new TypeError(`Processing output conflicts with stream ${id}`); }
|
|
117
|
+
deliverable.set(id, output);
|
|
118
|
+
}
|
|
119
|
+
const aliases = [...streams.values()].filter(({ output }) => { return output !== undefined; });
|
|
120
|
+
for (const stream of aliases) {
|
|
121
|
+
const prior = deliverable.get(stream.output);
|
|
122
|
+
if (typeof stream.output !== 'string' || !stream.output || (prior && prior.type !== stream.type)) {
|
|
123
|
+
throw new TypeError(`Invalid output alias for stream ${stream.id}`);
|
|
124
|
+
}
|
|
125
|
+
if (!prior) { deliverable.set(stream.output, { type: stream.type }); }
|
|
126
|
+
}
|
|
127
|
+
return deliverable;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
function knownControlNodes(nodes, serverIds) {
|
|
131
|
+
const members = new Set(nodes.map(({ id }) => { return id; }));
|
|
132
|
+
if (members.size !== nodes.length) { throw new TypeError('Invalid control membership'); }
|
|
133
|
+
if ([...members].some((id) => { return !serverIds.has(id); })) { throw new TypeError('Unknown control node'); }
|
|
134
|
+
return members;
|
|
135
|
+
}
|
|
136
|
+
|
|
52
137
|
/** Resolve named collection inputs without assigning readers to machines. */
|
|
53
138
|
export function resolveCollection(document) {
|
|
54
|
-
const { controlPlane, sources, streams, mappings = {}, servers = [], delivery = {},
|
|
139
|
+
const { controlPlane, sources, streams, mappings = {}, servers = [], delivery = {}, externalPublications = {} } = document;
|
|
55
140
|
const serverIds = new Set(servers.map(({ id }) => { return id; }));
|
|
56
|
-
const controlNodes =
|
|
57
|
-
if ([...controlNodes].some((id) => { return !serverIds.has(id); })) { throw new TypeError('Unknown control node'); }
|
|
141
|
+
const controlNodes = knownControlNodes(controlPlane?.nodes ?? [], serverIds);
|
|
58
142
|
const resolved = new Map(Object.entries(asMap(streams, 'Streams')).map(([id, stream]) => {
|
|
59
143
|
return [id, resolveStream(id, stream, sources, mappings)];
|
|
60
144
|
}));
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
145
|
+
const physical = new Map([...resolved].filter(([, stream]) => { return stream.source.mode !== 'push'; }));
|
|
146
|
+
const objectOwners = placementMap(document, serverIds);
|
|
147
|
+
const workloads = resolveWorkloads(document);
|
|
148
|
+
const outputs = processingOutputs(document, workloads);
|
|
149
|
+
const deliverable = outputStreams(resolved, outputs);
|
|
150
|
+
const destinations = routes(delivery, deliverable, serverIds, objectOwners);
|
|
151
|
+
const readers = resolveReaders(controlPlane?.readers, physical, controlNodes, objectOwners);
|
|
152
|
+
return {
|
|
153
|
+
readers, delivery: destinations, objectOwners, externalPublications, outputs,
|
|
154
|
+
events: [...eventRoutes({ document, streams: resolved, outputs, delivery: destinations, owners: objectOwners, workloads }),
|
|
155
|
+
...readerEvents(readers, deliverable, destinations, objectOwners)]
|
|
156
|
+
};
|
|
68
157
|
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
function machineType(template, types) {
|
|
2
|
+
return Object.entries(types).find(([, type]) => { return type.signalTemplates?.includes(template); })?.[0];
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
function machinesAt(nodes, types, parent = '') {
|
|
6
|
+
return (nodes ?? []).flatMap(({ id, template, nodes: children }) => {
|
|
7
|
+
const path = parent ? `${parent}/${id}` : id;
|
|
8
|
+
const type = template && machineType(template, types);
|
|
9
|
+
return [...(type ? [{ id, path, type }] : []), ...machinesAt(children, types, path)];
|
|
10
|
+
});
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Load profiles by the machine type that uses them, sharing profile files when possible. */
|
|
14
|
+
export function readProcessingProfiles(document, load, parse) {
|
|
15
|
+
const files = new Map();
|
|
16
|
+
const profiles = Object.entries(document.machineTypes ?? {}).flatMap(([type, { processingProfile }]) => {
|
|
17
|
+
if (processingProfile === undefined) { return []; }
|
|
18
|
+
if (typeof processingProfile !== 'string' || !processingProfile.trim()) {
|
|
19
|
+
throw new TypeError(`Invalid processing profile for ${type}`);
|
|
20
|
+
}
|
|
21
|
+
if (!files.has(processingProfile)) { files.set(processingProfile, parse(load(processingProfile), load)); }
|
|
22
|
+
return [[type, files.get(processingProfile)]];
|
|
23
|
+
});
|
|
24
|
+
return profiles.length ? { ...document, processingProfiles: Object.fromEntries(profiles) } : document;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function chooseMachines(all, id, selector) {
|
|
28
|
+
const matches = selector?.type
|
|
29
|
+
? all.filter(({ type }) => { return type === selector.type; })
|
|
30
|
+
: all.filter(({ id: short, path }) => { return id === short || id === path; });
|
|
31
|
+
if (!matches.length || (!selector?.type && matches.length !== 1)) {
|
|
32
|
+
throw new TypeError(`Invalid workload machine assignment ${id}`);
|
|
33
|
+
}
|
|
34
|
+
return matches;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
function assignmentEntries(all, workload, serverIds) {
|
|
38
|
+
const nodes = workload.placement?.nodes;
|
|
39
|
+
if (!Array.isArray(nodes) || !nodes.length || new Set(nodes).size !== nodes.length || nodes.some((node) => { return !serverIds.has(node); })) {
|
|
40
|
+
throw new TypeError('Invalid workload placement');
|
|
41
|
+
}
|
|
42
|
+
return Object.entries(workload.assignments ?? {}).map(([id, assignment]) => {
|
|
43
|
+
const { preferred, standby } = assignment.placement ?? {};
|
|
44
|
+
const eligible = [preferred, standby].filter((node) => { return node !== undefined; });
|
|
45
|
+
if (!eligible.length || new Set(eligible).size !== eligible.length || eligible.some((node) => { return !nodes.includes(node); })) {
|
|
46
|
+
throw new TypeError(`Invalid workload placement for ${id}`);
|
|
47
|
+
}
|
|
48
|
+
return { id, nodes: eligible, machines: chooseMachines(all, id, assignment.machines) };
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Bind logical processing work to machine types without tying runtime ownership to its prerequisites. */
|
|
53
|
+
export function resolveWorkloads(document) {
|
|
54
|
+
const all = machinesAt(document.namespace, document.machineTypes ?? {});
|
|
55
|
+
const serverIds = new Set((document.servers ?? []).map(({ id }) => { return id; }));
|
|
56
|
+
return Object.fromEntries(Object.entries(document.controlPlane?.workloads ?? {}).map(([id, workload]) => {
|
|
57
|
+
const { run } = workload;
|
|
58
|
+
if (typeof run !== 'string' || !run) { throw new TypeError(`Workload ${id} requires a runtime`); }
|
|
59
|
+
const assignments = assignmentEntries(all, workload, serverIds);
|
|
60
|
+
return [id, { run, nodes: workload.placement.nodes, assignments }];
|
|
61
|
+
}));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function addOutputs(outputs, declarations, producer) {
|
|
65
|
+
for (const [id, declaration] of Object.entries(declarations ?? {})) {
|
|
66
|
+
const prior = outputs.get(id);
|
|
67
|
+
if (typeof declaration?.type !== 'string' || !declaration.type || (prior && declaration.type !== prior.type)) {
|
|
68
|
+
throw new TypeError(`Invalid or conflicting processing output ${id}`);
|
|
69
|
+
}
|
|
70
|
+
if (!prior) { outputs.set(id, { type: declaration.type, producers: [] }); }
|
|
71
|
+
outputs.get(id).producers.push(producer);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** Map output streams to their processing workloads and eligible publishers. */
|
|
76
|
+
export function processingOutputs(document, workloads = resolveWorkloads(document)) {
|
|
77
|
+
const outputs = new Map();
|
|
78
|
+
for (const [workload, { assignments }] of Object.entries(workloads)) {
|
|
79
|
+
for (const { machines, nodes } of assignments) {
|
|
80
|
+
for (const { path: machine, type } of machines) {
|
|
81
|
+
addOutputs(outputs, document.processingProfiles?.[type]?.outputs, { workload, machine, nodes });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return Object.fromEntries(outputs);
|
|
86
|
+
}
|
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
import deploymentTemplate from '../../infrastructure/deploy/deploymentTemplate.js';
|
|
2
|
+
import { profileDefinitionFor } from './releaseNodes.js';
|
|
3
|
+
import { expandProfiles } from './expandProfiles.js';
|
|
4
|
+
|
|
5
|
+
function resources(cpu, memory, maxCpu, maxMemory) {
|
|
6
|
+
return { requests: { cpu, memory }, limits: { cpu: maxCpu, memory: maxMemory } };
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const controlDefaults = {
|
|
10
|
+
authUsernameKey: 'username', authPasswordKey: 'password', replacementDelayMs: 30000, clockSkewMs: 5000,
|
|
11
|
+
initialClusterState: 'new', autoCompactionRetention: '1h', storage: '4Gi', storageClass: 'local-path',
|
|
12
|
+
queueMaxBytes: 16777216, queueMaxRecords: 8192,
|
|
13
|
+
agentResources: resources('100m', '128Mi', '1', '640Mi'),
|
|
14
|
+
memberResources: resources('100m', '96Mi', '500m', '256Mi'),
|
|
15
|
+
controllerResources: resources('25m', '32Mi', '250m', '128Mi'),
|
|
16
|
+
historyResources: resources('50m', '96Mi', '500m', '384Mi')
|
|
17
|
+
};
|
|
2
18
|
|
|
3
19
|
function nodeSettings(node, deployment) {
|
|
4
20
|
const profile = node.agentProfile;
|
|
@@ -35,3 +51,30 @@ export default function normalizeControlPlane(raw) {
|
|
|
35
51
|
nodes: nodes.map((node) => { return nodeSettings(node, deployment); })
|
|
36
52
|
};
|
|
37
53
|
}
|
|
54
|
+
|
|
55
|
+
function serverSettings(document, node) {
|
|
56
|
+
const server = document.servers?.find(({ id }) => { return id === node.id; });
|
|
57
|
+
const profile = server?.profile && profileDefinitionFor(document, server);
|
|
58
|
+
const agent = profile?.apps?.scada?.collector?.controlAgent;
|
|
59
|
+
return { ...node, ...(agent && { agent: { ...agent, ...node.agent } }) };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Bind a named topology to its installation's Kubernetes, credentials and release settings. */
|
|
63
|
+
export function bindControlInstallation(document, installation, images = {}) {
|
|
64
|
+
const plane = document.controlPlane;
|
|
65
|
+
const { etcd = {}, secrets = {}, ...release } = installation;
|
|
66
|
+
const deployment = {
|
|
67
|
+
nodeTlsSecretTemplate: secrets.nodeTls, catalogSecret: secrets.catalog, deliverySecret: secrets.delivery,
|
|
68
|
+
...plane.deployment, images: { ...plane.deployment?.images, ...images }
|
|
69
|
+
};
|
|
70
|
+
const input = { ...document, profiles: expandProfiles(document.profiles ?? {}) };
|
|
71
|
+
return normalizeControlPlane({
|
|
72
|
+
...controlDefaults, ...release, ...etcd,
|
|
73
|
+
controllerAuthSecret: secrets.controllerAuth, controllerTlsSecret: secrets.controllerTls,
|
|
74
|
+
controllerEnabled: true, classifyApply: Object.values(plane.workloads ?? {}).some(({ assignments }) => {
|
|
75
|
+
return Object.keys(assignments ?? {}).length > 0;
|
|
76
|
+
}),
|
|
77
|
+
...plane, deployment,
|
|
78
|
+
nodes: (plane.nodes ?? []).map((node) => { return serverSettings(input, node); })
|
|
79
|
+
});
|
|
80
|
+
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { resolveCollection } from './namedCollection.js';
|
|
2
2
|
import { fits, zipped } from './expandPattern.js';
|
|
3
|
+
import { profileDefinitionFor } from './releaseNodes.js';
|
|
3
4
|
|
|
4
5
|
function addPublications(servers, declarations) {
|
|
5
6
|
for (const [node, publications] of Object.entries(declarations)) {
|
|
@@ -42,22 +43,22 @@ function addExternalRoutes(servers, primary, stream, route, declarations) {
|
|
|
42
43
|
}
|
|
43
44
|
|
|
44
45
|
function deliveryApi(plane, objectOwners, origin, path) {
|
|
45
|
-
const { addressApi, brokerApi } = plane.deployment ?? {};
|
|
46
|
+
const { addressApi = 'plant', brokerApi = 'bus' } = plane.deployment ?? {};
|
|
46
47
|
const owns = Object.entries(objectOwners).some(([object, owner]) => {
|
|
47
|
-
return owner === origin && (path === object || path.startsWith(`${object}/`));
|
|
48
|
+
return owner === origin.id && (path === object || path.startsWith(`${object}/`));
|
|
48
49
|
});
|
|
49
|
-
return owns ? addressApi : brokerApi;
|
|
50
|
+
return owns && origin.api?.some(({ id }) => { return id === addressApi; }) ? addressApi : brokerApi;
|
|
50
51
|
}
|
|
51
52
|
|
|
52
|
-
function brokerServices(servers,
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
const address = server.api?.find(({ id }) => { return
|
|
60
|
-
if (address) {
|
|
53
|
+
function brokerServices(servers, document) {
|
|
54
|
+
const plane = document.controlPlane;
|
|
55
|
+
const { addressApi = 'plant', brokerApi = 'bus' } = plane.deployment ?? {};
|
|
56
|
+
for (const { id } of plane.nodes) {
|
|
57
|
+
const server = servers.get(id);
|
|
58
|
+
const peer = server.profile && profileDefinitionFor(document, server).modules?.message_bus?.peerService;
|
|
59
|
+
const port = peer?.nodePort ?? plane.brokerService?.nodePort;
|
|
60
|
+
const address = server.api?.find(({ id: api }) => { return api === addressApi; });
|
|
61
|
+
if (port && address && !server.api.some(({ id: api }) => { return api === brokerApi; })) {
|
|
61
62
|
const { hostname } = new URL(address.url);
|
|
62
63
|
server.api = [...server.api, { id: brokerApi, url: `amqp://${hostname}:${port}` }];
|
|
63
64
|
}
|
|
@@ -82,18 +83,19 @@ function routeServers(declarations, objectOwners) {
|
|
|
82
83
|
/** Derive the static transport view used by runtime and broker plan consumers. */
|
|
83
84
|
export default function projectCollectionRoutes(document) {
|
|
84
85
|
if (document.controlPlane?.readers === undefined) { return document; }
|
|
85
|
-
const { readers, delivery, objectOwners, externalPublications } = resolveCollection(document);
|
|
86
|
+
const { readers, delivery, objectOwners, externalPublications, events } = resolveCollection(document);
|
|
86
87
|
const servers = routeServers(document.servers, objectOwners);
|
|
87
|
-
brokerServices(servers, document
|
|
88
|
+
brokerServices(servers, document);
|
|
88
89
|
addPublications(servers, externalPublications);
|
|
89
90
|
for (const { eligible: [primary], streams } of readers) {
|
|
90
91
|
const origin = servers.get(primary);
|
|
91
|
-
for (const stream of streams) {
|
|
92
|
-
|
|
92
|
+
for (const stream of streams.filter(({ from }) => { return typeof from === 'string'; })) {
|
|
93
|
+
const { from, path: name, mapping, sampling } = stream;
|
|
94
|
+
origin.fan_in.push({ from, name, ...(mapping !== undefined && { mapping }), ...(sampling !== undefined && { sampling }) });
|
|
93
95
|
const route = delivery[stream.id];
|
|
94
|
-
addRoute(servers, origin, stream, route, deliveryApi(document.controlPlane, objectOwners, origin
|
|
96
|
+
addRoute(servers, origin, stream, route, deliveryApi(document.controlPlane, objectOwners, origin, stream.path));
|
|
95
97
|
addExternalRoutes(servers, primary, stream, route, externalPublications);
|
|
96
98
|
}
|
|
97
99
|
}
|
|
98
|
-
return { ...document, servers: [...servers.values()] };
|
|
100
|
+
return { ...document, servers: [...servers.values()], eventDelivery: events };
|
|
99
101
|
}
|
|
@@ -35,10 +35,10 @@ function chartValues(config, server, servers, policy, ports) {
|
|
|
35
35
|
|
|
36
36
|
/** Project one control release from a plant document and supplied policy and runtime bindings. */
|
|
37
37
|
export default function projectControlPlane(cluster, document, policy, ports) {
|
|
38
|
-
const
|
|
38
|
+
const { servers } = projectCollectionRoutes(document);
|
|
39
|
+
const config = controlPlaneConfiguration(normalizeControlPlane(document[policy.section]), servers, policy);
|
|
39
40
|
const server = config.nodes.find(({ id }) => { return id === cluster; });
|
|
40
41
|
if (!server) { throw new TypeError(`Unknown edge ${cluster}`); }
|
|
41
|
-
const { servers } = projectCollectionRoutes(document);
|
|
42
42
|
const catalog = ports.catalog(document, config);
|
|
43
43
|
const classification = ports.classification(document, config, catalog);
|
|
44
44
|
return {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import readDocumentFile, { selectDeploymentPhase } from './readDocumentFile.js';
|
|
2
2
|
import readDocument from './readDocument.js';
|
|
3
3
|
import resolveDeploymentRouting from './deploymentRouting.js';
|
|
4
|
+
import { readProcessingProfiles } from './namedProcessing.js';
|
|
4
5
|
|
|
5
6
|
function fileSelection(file) {
|
|
6
7
|
if (file instanceof URL) {
|
|
@@ -35,7 +36,10 @@ function controlFragments(document, load, parse) {
|
|
|
35
36
|
/** A deployment document can declare its phase policy and be opened as path#phase. */
|
|
36
37
|
export default function readDeploymentDocument(file, parse = readDocument) {
|
|
37
38
|
const { path, phase } = fileSelection(file);
|
|
38
|
-
const loaded = readDocumentFile(path, (text, load) => {
|
|
39
|
+
const loaded = readDocumentFile(path, (text, load) => {
|
|
40
|
+
const document = controlFragments(parse(text, load), load, parse);
|
|
41
|
+
return readProcessingProfiles(document, load, parse);
|
|
42
|
+
});
|
|
39
43
|
const { deploymentPhase: policy, ...document } = resolveDeploymentRouting(loaded);
|
|
40
44
|
if (policy === undefined) {
|
|
41
45
|
if (phase !== undefined) { throw new TypeError('Deployment phase policy is missing'); }
|
|
@@ -110,6 +110,7 @@ export default async function plantServer(config) {
|
|
|
110
110
|
heartbeat: config.heartbeat || 1000,
|
|
111
111
|
requestTimeoutMs,
|
|
112
112
|
extraRoutes: extra,
|
|
113
|
+
tagCatalog: config.tagCatalog,
|
|
113
114
|
timelineOperator: config.timelineOperator,
|
|
114
115
|
operationDecisions: config.operationDecisions,
|
|
115
116
|
owners: config.owners,
|
|
@@ -167,6 +167,7 @@ export default async function siteServer(config) {
|
|
|
167
167
|
port: config.port || parseInt(env.PORT || '3000', 10),
|
|
168
168
|
basePath,
|
|
169
169
|
translations: config.translations,
|
|
170
|
+
tagCatalog: config.tagCatalog,
|
|
170
171
|
requirePool: config.requirePool,
|
|
171
172
|
stomp: stompFromEnv(env),
|
|
172
173
|
plantFactory: plantFactoryWithOperations(config.plantFactory, ops, sink),
|
|
@@ -3,19 +3,20 @@ import { readFileSync } from 'node:fs';
|
|
|
3
3
|
/**
|
|
4
4
|
* Loads hierarchical tag catalog entries from a configured JSON file.
|
|
5
5
|
*
|
|
6
|
-
* Uses
|
|
6
|
+
* Uses the declared catalog when TAG_CATALOG_PATH is unset.
|
|
7
7
|
*
|
|
8
8
|
* @example
|
|
9
9
|
* const catalog = tagCatalog({ TAG_CATALOG_PATH: '/etc/scada/tag-catalog.json' });
|
|
10
10
|
* catalog.labels();
|
|
11
11
|
*
|
|
12
12
|
* @param {object} [env] - environment map, defaults to process.env
|
|
13
|
+
* @param {Array<object>} [fallback] - declared catalog rows
|
|
13
14
|
* @returns {object} catalog with entries(), labels(), children(parent)
|
|
14
15
|
*/
|
|
15
|
-
export default function tagCatalog(env) {
|
|
16
|
+
export default function tagCatalog(env, fallback = []) {
|
|
16
17
|
const source = env || process.env;
|
|
17
18
|
const path = source.TAG_CATALOG_PATH;
|
|
18
|
-
const raw = path ? JSON.parse(readFileSync(path, 'utf8')) :
|
|
19
|
+
const raw = path ? JSON.parse(readFileSync(path, 'utf8')) : fallback.slice();
|
|
19
20
|
if (!Array.isArray(raw)) {
|
|
20
21
|
throw new Error('tag catalog must be a JSON array');
|
|
21
22
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { expandProfiles } from '../../application/deploy/expandProfiles.js';
|
|
2
|
+
import { profileFor } from '../../application/deploy/releaseNodes.js';
|
|
1
3
|
import readDeploymentDocument from '../../application/deploy/readDeploymentDocument.js';
|
|
2
4
|
import centralTelemetryPolicy, { centralTelemetryVersion, normalizeCentralPolicy } from '../ingest/telemetry/centralPolicy.js';
|
|
3
5
|
|
|
@@ -5,7 +7,14 @@ const policyRuntime = { centralTelemetryPolicy, centralTelemetryVersion };
|
|
|
5
7
|
const metricsAdapters = new Set(['amqp-metrics', 'mqtt-metrics', 'amqp-pg-metrics', 'mqtt-pg-metrics', 'silent-streams']);
|
|
6
8
|
|
|
7
9
|
export function centralTelemetryValues(document) {
|
|
8
|
-
return normalizeCentralPolicy(document.centralTelemetry);
|
|
10
|
+
if (Object.hasOwn(document, 'centralTelemetry')) { return normalizeCentralPolicy(document.centralTelemetry); }
|
|
11
|
+
const profiles = expandProfiles(document.profiles ?? {});
|
|
12
|
+
const stores = (document.servers ?? []).filter(({ profile }) => { return profile?.id && profiles[profile.id]; }).map((server) => {
|
|
13
|
+
return profileFor({ ...document, profiles }, server).modules?.telemetry_store;
|
|
14
|
+
}).filter((store) => { return store?.policy && store.enabled !== false; });
|
|
15
|
+
const store = stores[0] ?? profiles.archive?.modules?.telemetry_store;
|
|
16
|
+
if (stores.length > 1) { throw new TypeError('Central telemetry policy requires a single archive store'); }
|
|
17
|
+
return normalizeCentralPolicy(store?.policy ? { enabled: store.enabled, ...store.policy } : undefined);
|
|
9
18
|
}
|
|
10
19
|
|
|
11
20
|
export function centralTelemetryChartEnv(document, file, previous = []) {
|
|
@@ -16,7 +16,7 @@ function compileCollectors(context, policy, ports) {
|
|
|
16
16
|
const machines = scada.machines.filter(({ from }) => {
|
|
17
17
|
return !policy.excludedSources.some((prefix) => { return from.startsWith(prefix); });
|
|
18
18
|
});
|
|
19
|
-
const sources = ports.processes(machines, app);
|
|
19
|
+
const sources = ports.processes(machines, app, context);
|
|
20
20
|
const initial = sources[0];
|
|
21
21
|
const defaults = initial ? deploymentTemplate(policy.environment, target) : {};
|
|
22
22
|
const environment = Object.fromEntries(Object.entries(defaults).map(([key, value]) => {
|
|
@@ -46,7 +46,7 @@ export default function configuredBundleCapabilities(policy, runtime) {
|
|
|
46
46
|
try {
|
|
47
47
|
installBundle(artifact, volume, execute, kube);
|
|
48
48
|
const candidates = bundleCandidates(policy.applicationBundle, runtime, artifact, volume);
|
|
49
|
-
const
|
|
49
|
+
const protocol = deploymentTemplate(policy.applicationBundle.protocol ?? policy.selection.protocol, plan);
|
|
50
50
|
verifyRuntimeCapabilities({ candidates, required: [protocol], match: policy.match,
|
|
51
51
|
subject: policy.subject, mismatch: policy.mismatch }, execute);
|
|
52
52
|
} finally {
|
|
@@ -30,9 +30,10 @@ export { default as applyWhenChanged } from './applyWhenChanged.js';
|
|
|
30
30
|
export { default as prepareKubePrerequisites } from './prepareKubePrerequisites.js';
|
|
31
31
|
export { default as readDeploymentDocument } from '../../application/deploy/readDeploymentDocument.js';
|
|
32
32
|
export { resolveCollection } from '../../application/deploy/namedCollection.js';
|
|
33
|
+
export { resolveWorkloads } from '../../application/deploy/namedProcessing.js';
|
|
33
34
|
export { default as compileNamedControlCatalog } from '../../application/deploy/compileNamedControlCatalog.js';
|
|
34
|
-
export { default as compileLocalConsumers } from '../../application/deploy/compileLocalConsumers.js';
|
|
35
|
-
export { default as normalizeControlPlane } from '../../application/deploy/normalizeControlPlane.js';
|
|
35
|
+
export { default as compileLocalConsumers, namedLocalConsumers } from '../../application/deploy/compileLocalConsumers.js';
|
|
36
|
+
export { default as normalizeControlPlane, bindControlInstallation } from '../../application/deploy/normalizeControlPlane.js';
|
|
36
37
|
export { profileDefinitionFor } from '../../application/deploy/releaseNodes.js';
|
|
37
38
|
export { sourceAddress } from '../../application/deploy/deploymentRouting.js';
|
|
38
39
|
export { appendReplicaTopology, replicaShovels, brokerReplicaPlan, appendBrokerReplicas } from './brokerReplicaTopology.js';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { validateConnections } from './config.js';
|
|
2
2
|
|
|
3
3
|
/** Selects sampling policy by stream path while the fan-in remains the source inventory. */
|
|
4
|
-
function timing(name, config) {
|
|
5
|
-
const match = (config.sampling || []).find((item) => {
|
|
4
|
+
function timing({ name, sampling }, config) {
|
|
5
|
+
const match = sampling ?? (config.sampling || []).find((item) => {
|
|
6
6
|
const parts = item.name.split('/');
|
|
7
7
|
const path = name.split('/');
|
|
8
8
|
return parts.length === path.length && parts.every((part, index) => {
|
|
@@ -18,7 +18,7 @@ function timing(name, config) {
|
|
|
18
18
|
export default function projectOpcuaSources(rows, config, deviceFor) {
|
|
19
19
|
const connections = new Map();
|
|
20
20
|
rows.forEach((row) => {
|
|
21
|
-
const intervals = timing(row
|
|
21
|
+
const intervals = timing(row, config);
|
|
22
22
|
const connection = connections.get(row.from) || { url: row.from, ...intervals, channels: [] };
|
|
23
23
|
if (connection.publishMs !== intervals.publishMs || connection.heartbeatMs !== intervals.heartbeatMs || connection.healthRequired !== intervals.healthRequired) {
|
|
24
24
|
throw new Error(`incompatible OPC UA sampling policies at ${row.from}`);
|