@fastybird/smart-panel-backend 1.1.0-alpha.6 → 1.1.0-alpha.7
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/dist/modules/devices/devices.module.js +3 -0
- package/dist/modules/devices/devices.module.js.map +1 -1
- package/dist/modules/devices/services/channels.properties.service.d.ts +5 -1
- package/dist/modules/devices/services/channels.properties.service.js +40 -9
- package/dist/modules/devices/services/channels.properties.service.js.map +1 -1
- package/dist/modules/devices/services/command-latency-trace-collector.service.d.ts +100 -0
- package/dist/modules/devices/services/command-latency-trace-collector.service.js +438 -0
- package/dist/modules/devices/services/command-latency-trace-collector.service.js.map +1 -0
- package/dist/modules/devices/services/property-command-dispatch.service.d.ts +3 -1
- package/dist/modules/devices/services/property-command-dispatch.service.js +19 -10
- package/dist/modules/devices/services/property-command-dispatch.service.js.map +1 -1
- package/dist/modules/devices/services/property-command-window.service.d.ts +1 -0
- package/dist/modules/devices/services/property-command-window.service.js +4 -0
- package/dist/modules/devices/services/property-command-window.service.js.map +1 -1
- package/dist/modules/devices/services/property-command.service.d.ts +3 -1
- package/dist/modules/devices/services/property-command.service.js +14 -2
- package/dist/modules/devices/services/property-command.service.js.map +1 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js +2 -1
- package/dist/plugins/devices-home-assistant/services/home-assistant.ws.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.d.ts +5 -1
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js +94 -23
- package/dist/plugins/devices-shelly-ng/delegates/delegates-manager.service.js.map +1 -1
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.d.ts +4 -0
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js +43 -2
- package/dist/plugins/devices-shelly-ng/delegates/shelly-device.delegate.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var CommandLatencyTraceCollectorService_1;
|
|
15
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
16
|
+
exports.CommandLatencyTraceCollectorService = exports.COMMAND_LATENCY_TRACE_OPTIONS = void 0;
|
|
17
|
+
const node_async_hooks_1 = require("node:async_hooks");
|
|
18
|
+
const node_crypto_1 = require("node:crypto");
|
|
19
|
+
const node_fs_1 = require("node:fs");
|
|
20
|
+
const promises_1 = require("node:fs/promises");
|
|
21
|
+
const node_perf_hooks_1 = require("node:perf_hooks");
|
|
22
|
+
const common_1 = require("@nestjs/common");
|
|
23
|
+
exports.COMMAND_LATENCY_TRACE_OPTIONS = Symbol('COMMAND_LATENCY_TRACE_OPTIONS');
|
|
24
|
+
const MAX_CAPTURE_DURATION_MS = 30_000;
|
|
25
|
+
const MAX_CAPTURE_RECORDS = 4_096;
|
|
26
|
+
let CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService_1 = class CommandLatencyTraceCollectorService {
|
|
27
|
+
constructor(options) {
|
|
28
|
+
this.context = new node_async_hooks_1.AsyncLocalStorage();
|
|
29
|
+
this.trialsByIntent = new Map();
|
|
30
|
+
this.trialsByGeneration = new Map();
|
|
31
|
+
this.captures = [];
|
|
32
|
+
this.pendingExports = new Set();
|
|
33
|
+
this.exportTasks = new Set();
|
|
34
|
+
this.recordCount = 0;
|
|
35
|
+
this.overflowed = false;
|
|
36
|
+
this.config = normalizeConfig(options ?? parseEnvironmentConfig());
|
|
37
|
+
this.collectorHash = CommandLatencyTraceCollectorService_1.getSourceHash();
|
|
38
|
+
}
|
|
39
|
+
static getSourceHash() {
|
|
40
|
+
try {
|
|
41
|
+
return (0, node_crypto_1.createHash)('sha256').update((0, node_fs_1.readFileSync)(__filename, 'utf8')).digest('hex');
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return (0, node_crypto_1.createHash)('sha256').update(CommandLatencyTraceCollectorService_1.toString()).digest('hex');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
isEnabled() {
|
|
48
|
+
return this.config !== null && !this.overflowed;
|
|
49
|
+
}
|
|
50
|
+
observeCommand(command) {
|
|
51
|
+
if (!this.isEnabled() || !command.requestId || this.config === null) {
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
this.expireDueTrials();
|
|
55
|
+
const matching = command.properties.filter((property) => property.property === this.config.sourcePropertyId || property.property === this.config.projectionPropertyId);
|
|
56
|
+
if (matching.length !== 1) {
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
const selected = matching[0];
|
|
60
|
+
if (selected === undefined || this.trialsByIntent.has(command.intentId)) {
|
|
61
|
+
return;
|
|
62
|
+
}
|
|
63
|
+
const startedAtMs = this.now();
|
|
64
|
+
const expiryTimer = setTimeout(() => this.expireTrial(command.intentId), this.config.captureDurationMs);
|
|
65
|
+
expiryTimer.unref();
|
|
66
|
+
const trial = {
|
|
67
|
+
trialId: command.requestId,
|
|
68
|
+
intentId: command.intentId,
|
|
69
|
+
requestedPropertyId: selected.property,
|
|
70
|
+
commandValue: selected.value,
|
|
71
|
+
startedAtMs,
|
|
72
|
+
expiryTimer,
|
|
73
|
+
pendingRecords: [],
|
|
74
|
+
completed: false,
|
|
75
|
+
activeInvocationCount: 0,
|
|
76
|
+
};
|
|
77
|
+
this.trialsByIntent.set(trial.intentId, trial);
|
|
78
|
+
this.recordTrial(trial, 'command-received', undefined, { requestedPropertyId: selected.property });
|
|
79
|
+
}
|
|
80
|
+
bindWindow(intentId, sourcePropertyId, windowGeneration) {
|
|
81
|
+
if (!this.isEnabled() || !intentId || this.config === null || sourcePropertyId !== this.config.sourcePropertyId) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this.expireDueTrials();
|
|
85
|
+
const trial = this.trialsByIntent.get(intentId);
|
|
86
|
+
if (trial === undefined || trial.completed) {
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (trial.windowGeneration !== undefined && trial.windowGeneration !== windowGeneration) {
|
|
90
|
+
this.finishTrial(trial, 'error', 'A validation trial was bound to more than one command-window generation.');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const colliding = this.trialsByGeneration.get(windowGeneration);
|
|
94
|
+
if (colliding !== undefined && colliding !== trial) {
|
|
95
|
+
this.finishTrial(colliding, 'error', 'A command-window generation was correlated to multiple validation trials.');
|
|
96
|
+
this.finishTrial(trial, 'error', 'A command-window generation was correlated to multiple validation trials.');
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
trial.windowGeneration = windowGeneration;
|
|
100
|
+
this.trialsByGeneration.set(windowGeneration, trial);
|
|
101
|
+
this.recordTrial(trial, 'window-bound');
|
|
102
|
+
}
|
|
103
|
+
recordProviderReceipt(propertyId, value, origin, metadata) {
|
|
104
|
+
const trial = this.getBoundTrial(propertyId);
|
|
105
|
+
if (trial === null) {
|
|
106
|
+
return;
|
|
107
|
+
}
|
|
108
|
+
this.recordTrial(trial, 'provider-receipt', undefined, { origin, receivedValue: value, ...metadata });
|
|
109
|
+
}
|
|
110
|
+
recordPollActivity(propertyId, stage, metadata) {
|
|
111
|
+
const trial = this.getBoundTrial(propertyId);
|
|
112
|
+
if (trial !== null) {
|
|
113
|
+
this.recordTrial(trial, stage, undefined, metadata);
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
recordPollRpc(deviceId, stage, metadata) {
|
|
117
|
+
if (!this.isEnabled() || this.config?.sourceDeviceId !== deviceId) {
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
for (const trial of this.trialsByGeneration.values()) {
|
|
121
|
+
if (!trial.completed) {
|
|
122
|
+
this.recordTrial(trial, stage, undefined, { deviceId, ...metadata });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async traceUpdate(input, callback) {
|
|
127
|
+
const invocation = this.beginInvocation(input);
|
|
128
|
+
if (invocation === null) {
|
|
129
|
+
return callback();
|
|
130
|
+
}
|
|
131
|
+
return this.context.run(invocation, async () => {
|
|
132
|
+
try {
|
|
133
|
+
const result = await callback();
|
|
134
|
+
this.finishInvocation(invocation);
|
|
135
|
+
return result;
|
|
136
|
+
}
|
|
137
|
+
catch (error) {
|
|
138
|
+
invocation.status = 'error';
|
|
139
|
+
invocation.failureReason = error instanceof Error ? error.message : 'Unknown update failure';
|
|
140
|
+
this.recordInvocation(invocation, 'update-error', { reason: invocation.failureReason });
|
|
141
|
+
this.finishInvocation(invocation);
|
|
142
|
+
throw error;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
recordWriteComplete(property, metadata) {
|
|
147
|
+
this.recordCurrentInvocation('write-complete', property.id, metadata);
|
|
148
|
+
}
|
|
149
|
+
recordSuppressed(property, reason) {
|
|
150
|
+
const invocation = this.context.getStore();
|
|
151
|
+
if (invocation === undefined || property.id !== this.config?.sourcePropertyId) {
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
invocation.status = 'suppressed';
|
|
155
|
+
this.recordInvocation(invocation, 'suppressed', { reason });
|
|
156
|
+
}
|
|
157
|
+
recordSourcePublication(property) {
|
|
158
|
+
const invocation = this.context.getStore() ?? this.getActiveInvocation(property.id);
|
|
159
|
+
if (invocation === undefined || property.id !== this.config?.sourcePropertyId) {
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
const publishedValue = property.value?.value;
|
|
163
|
+
if (publishedValue !== invocation.trial.commandValue) {
|
|
164
|
+
invocation.status = 'error';
|
|
165
|
+
invocation.failureReason = 'Canonical source publication did not match the commanded value.';
|
|
166
|
+
this.recordInvocation(invocation, 'update-error', { reason: invocation.failureReason, publishedValue });
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
this.recordInvocation(invocation, 'source-publication');
|
|
170
|
+
this.recordInvocation(invocation, 'update-complete');
|
|
171
|
+
this.finishTrial(invocation.trial, 'complete', undefined, invocation);
|
|
172
|
+
}
|
|
173
|
+
getCaptures() {
|
|
174
|
+
this.expireDueTrials();
|
|
175
|
+
return this.captures.map((capture) => ({ ...capture, records: [...capture.records] }));
|
|
176
|
+
}
|
|
177
|
+
async waitForExports() {
|
|
178
|
+
await Promise.all([...this.exportTasks]);
|
|
179
|
+
}
|
|
180
|
+
onModuleDestroy() {
|
|
181
|
+
for (const trial of [...this.trialsByIntent.values()]) {
|
|
182
|
+
this.finishTrial(trial, 'shutdown', 'The backend stopped before the validation capture completed.');
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
beginInvocation(input) {
|
|
186
|
+
const trial = this.getBoundTrial(input.propertyId, input.windowGeneration);
|
|
187
|
+
if (trial === null || input.value === undefined) {
|
|
188
|
+
return null;
|
|
189
|
+
}
|
|
190
|
+
if (trial.activeInvocationCount > 0) {
|
|
191
|
+
this.finishTrial(trial, 'error', 'Concurrent provider updates share one command-window generation; server evidence is ambiguous.');
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
const invocation = {
|
|
195
|
+
invocationId: (0, node_crypto_1.randomUUID)(),
|
|
196
|
+
trial,
|
|
197
|
+
records: trial.pendingRecords.splice(0),
|
|
198
|
+
status: 'pending',
|
|
199
|
+
};
|
|
200
|
+
trial.activeInvocationCount++;
|
|
201
|
+
trial.activeInvocation = invocation;
|
|
202
|
+
this.recordInvocation(invocation, 'update-entry', { receivedValue: input.value });
|
|
203
|
+
return invocation;
|
|
204
|
+
}
|
|
205
|
+
finishInvocation(invocation) {
|
|
206
|
+
invocation.trial.activeInvocationCount = Math.max(0, invocation.trial.activeInvocationCount - 1);
|
|
207
|
+
if (invocation.trial.activeInvocation === invocation) {
|
|
208
|
+
invocation.trial.activeInvocation = undefined;
|
|
209
|
+
}
|
|
210
|
+
if (invocation.trial.completed) {
|
|
211
|
+
return;
|
|
212
|
+
}
|
|
213
|
+
const published = invocation.records.some((record) => record.stage === 'source-publication');
|
|
214
|
+
if (invocation.status === 'pending' && published) {
|
|
215
|
+
this.recordInvocation(invocation, 'update-complete');
|
|
216
|
+
this.finishTrial(invocation.trial, 'complete', undefined, invocation);
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
if (invocation.status === 'suppressed') {
|
|
220
|
+
this.finishTrial(invocation.trial, 'suppressed', undefined, invocation, false);
|
|
221
|
+
return;
|
|
222
|
+
}
|
|
223
|
+
if (invocation.status === 'error') {
|
|
224
|
+
this.finishTrial(invocation.trial, 'error', invocation.failureReason, invocation);
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
getActiveInvocation(propertyId) {
|
|
228
|
+
if (!this.isEnabled() || propertyId !== this.config?.sourcePropertyId) {
|
|
229
|
+
return undefined;
|
|
230
|
+
}
|
|
231
|
+
const candidates = [...this.trialsByGeneration.values()]
|
|
232
|
+
.filter((trial) => !trial.completed && trial.activeInvocation !== undefined)
|
|
233
|
+
.map((trial) => trial.activeInvocation)
|
|
234
|
+
.filter((invocation) => invocation !== undefined);
|
|
235
|
+
return candidates.length === 1 ? candidates[0] : undefined;
|
|
236
|
+
}
|
|
237
|
+
recordCurrentInvocation(stage, propertyId, metadata) {
|
|
238
|
+
const invocation = this.context.getStore();
|
|
239
|
+
if (invocation !== undefined && propertyId === this.config?.sourcePropertyId) {
|
|
240
|
+
this.recordInvocation(invocation, stage, metadata);
|
|
241
|
+
}
|
|
242
|
+
}
|
|
243
|
+
getBoundTrial(propertyId, windowGeneration) {
|
|
244
|
+
if (!this.isEnabled() || this.config === null || propertyId !== this.config.sourcePropertyId) {
|
|
245
|
+
return null;
|
|
246
|
+
}
|
|
247
|
+
this.expireDueTrials();
|
|
248
|
+
if (windowGeneration !== undefined) {
|
|
249
|
+
return this.trialsByGeneration.get(windowGeneration) ?? null;
|
|
250
|
+
}
|
|
251
|
+
const candidates = [...this.trialsByGeneration.values()].filter((trial) => !trial.completed);
|
|
252
|
+
return candidates.length === 1 ? (candidates[0] ?? null) : null;
|
|
253
|
+
}
|
|
254
|
+
recordTrial(trial, stage, invocationId, metadata) {
|
|
255
|
+
const record = this.createRecord(trial, stage, invocationId, metadata);
|
|
256
|
+
if (!this.acceptRecord(record)) {
|
|
257
|
+
return null;
|
|
258
|
+
}
|
|
259
|
+
if (invocationId === undefined) {
|
|
260
|
+
trial.pendingRecords.push(record);
|
|
261
|
+
}
|
|
262
|
+
return record;
|
|
263
|
+
}
|
|
264
|
+
recordInvocation(invocation, stage, metadata) {
|
|
265
|
+
if (invocation.trial.completed) {
|
|
266
|
+
return;
|
|
267
|
+
}
|
|
268
|
+
const record = this.recordTrial(invocation.trial, stage, invocation.invocationId, metadata);
|
|
269
|
+
if (record !== null) {
|
|
270
|
+
invocation.records.push(record);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
createRecord(trial, stage, invocationId, metadata) {
|
|
274
|
+
if (this.config === null) {
|
|
275
|
+
throw new Error('Cannot create a command latency trace record while capture is disabled.');
|
|
276
|
+
}
|
|
277
|
+
return Object.freeze({
|
|
278
|
+
stage,
|
|
279
|
+
timestampMs: this.now(),
|
|
280
|
+
processId: process.pid,
|
|
281
|
+
runId: this.config.runId,
|
|
282
|
+
trialId: trial.trialId,
|
|
283
|
+
invocationId,
|
|
284
|
+
sourcePropertyId: this.config.sourcePropertyId,
|
|
285
|
+
projectionPropertyId: this.config.projectionPropertyId,
|
|
286
|
+
commandValue: trial.commandValue,
|
|
287
|
+
intentId: trial.intentId,
|
|
288
|
+
windowGeneration: trial.windowGeneration,
|
|
289
|
+
metadata: metadata === undefined ? undefined : Object.freeze({ ...metadata }),
|
|
290
|
+
});
|
|
291
|
+
}
|
|
292
|
+
acceptRecord(_record) {
|
|
293
|
+
if (this.overflowed) {
|
|
294
|
+
return false;
|
|
295
|
+
}
|
|
296
|
+
if (this.recordCount >= (this.config?.maxRecords ?? 0)) {
|
|
297
|
+
this.overflowed = true;
|
|
298
|
+
for (const trial of [...this.trialsByIntent.values()]) {
|
|
299
|
+
this.finishTrial(trial, 'overflow', 'The bounded command latency capture exceeded its record limit.');
|
|
300
|
+
}
|
|
301
|
+
return false;
|
|
302
|
+
}
|
|
303
|
+
this.recordCount++;
|
|
304
|
+
return true;
|
|
305
|
+
}
|
|
306
|
+
finishTrial(trial, status, failureReason, invocation, finalize = true) {
|
|
307
|
+
if (trial.completed && finalize) {
|
|
308
|
+
return;
|
|
309
|
+
}
|
|
310
|
+
const records = invocation?.records ?? trial.pendingRecords;
|
|
311
|
+
const capture = Object.freeze({
|
|
312
|
+
schemaVersion: 1,
|
|
313
|
+
clock: 'backend-performance-now-v1',
|
|
314
|
+
collectorHash: this.collectorHash,
|
|
315
|
+
processId: process.pid,
|
|
316
|
+
runId: this.config?.runId ?? 'disabled',
|
|
317
|
+
trialId: trial.trialId,
|
|
318
|
+
invocationId: invocation?.invocationId,
|
|
319
|
+
sourcePropertyId: this.config?.sourcePropertyId ?? '',
|
|
320
|
+
projectionPropertyId: this.config?.projectionPropertyId,
|
|
321
|
+
commandValue: trial.commandValue,
|
|
322
|
+
intentId: trial.intentId,
|
|
323
|
+
windowGeneration: trial.windowGeneration,
|
|
324
|
+
status,
|
|
325
|
+
failureReason,
|
|
326
|
+
records: Object.freeze([...records]),
|
|
327
|
+
});
|
|
328
|
+
this.captures.push(capture);
|
|
329
|
+
this.scheduleExport(capture);
|
|
330
|
+
if (!finalize) {
|
|
331
|
+
return;
|
|
332
|
+
}
|
|
333
|
+
trial.completed = true;
|
|
334
|
+
trial.activeInvocation = undefined;
|
|
335
|
+
clearTimeout(trial.expiryTimer);
|
|
336
|
+
this.trialsByIntent.delete(trial.intentId);
|
|
337
|
+
if (trial.windowGeneration !== undefined && this.trialsByGeneration.get(trial.windowGeneration) === trial) {
|
|
338
|
+
this.trialsByGeneration.delete(trial.windowGeneration);
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
expireDueTrials() {
|
|
342
|
+
const captureDurationMs = this.config?.captureDurationMs;
|
|
343
|
+
if (captureDurationMs === undefined) {
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
const now = this.now();
|
|
347
|
+
for (const trial of [...this.trialsByIntent.values()]) {
|
|
348
|
+
if (now - trial.startedAtMs >= captureDurationMs) {
|
|
349
|
+
this.finishTrial(trial, 'expired', `The ${captureDurationMs}ms validation capture window elapsed before source publication.`);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
expireTrial(intentId) {
|
|
354
|
+
const captureDurationMs = this.config?.captureDurationMs;
|
|
355
|
+
const trial = this.trialsByIntent.get(intentId);
|
|
356
|
+
if (trial !== undefined && captureDurationMs !== undefined) {
|
|
357
|
+
this.finishTrial(trial, 'expired', `The ${captureDurationMs}ms validation capture window elapsed before source publication.`);
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
now() {
|
|
361
|
+
return node_perf_hooks_1.performance.now();
|
|
362
|
+
}
|
|
363
|
+
scheduleExport(capture) {
|
|
364
|
+
if (!this.config?.exportPath) {
|
|
365
|
+
return;
|
|
366
|
+
}
|
|
367
|
+
this.pendingExports.add(capture);
|
|
368
|
+
const task = new Promise((resolve) => {
|
|
369
|
+
setImmediate(() => {
|
|
370
|
+
void (0, promises_1.appendFile)(this.config?.exportPath ?? '', `${JSON.stringify(capture)}\n`, 'utf8')
|
|
371
|
+
.catch(() => {
|
|
372
|
+
this.replaceCaptureAfterSinkFailure(capture);
|
|
373
|
+
})
|
|
374
|
+
.finally(() => {
|
|
375
|
+
this.pendingExports.delete(capture);
|
|
376
|
+
this.exportTasks.delete(task);
|
|
377
|
+
resolve();
|
|
378
|
+
});
|
|
379
|
+
});
|
|
380
|
+
});
|
|
381
|
+
this.exportTasks.add(task);
|
|
382
|
+
}
|
|
383
|
+
replaceCaptureAfterSinkFailure(capture) {
|
|
384
|
+
const index = this.captures.indexOf(capture);
|
|
385
|
+
if (index === -1) {
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
this.captures[index] = Object.freeze({
|
|
389
|
+
...capture,
|
|
390
|
+
status: 'error',
|
|
391
|
+
failureReason: 'The private command latency capture sink failed to export this report.',
|
|
392
|
+
});
|
|
393
|
+
}
|
|
394
|
+
};
|
|
395
|
+
exports.CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService;
|
|
396
|
+
exports.CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService = CommandLatencyTraceCollectorService_1 = __decorate([
|
|
397
|
+
(0, common_1.Injectable)(),
|
|
398
|
+
__param(0, (0, common_1.Optional)()),
|
|
399
|
+
__param(0, (0, common_1.Inject)(exports.COMMAND_LATENCY_TRACE_OPTIONS)),
|
|
400
|
+
__metadata("design:paramtypes", [Object])
|
|
401
|
+
], CommandLatencyTraceCollectorService);
|
|
402
|
+
function parseEnvironmentConfig() {
|
|
403
|
+
const raw = process.env.FB_COMMAND_LATENCY_CAPTURE;
|
|
404
|
+
if (!raw) {
|
|
405
|
+
return null;
|
|
406
|
+
}
|
|
407
|
+
try {
|
|
408
|
+
return JSON.parse(raw);
|
|
409
|
+
}
|
|
410
|
+
catch {
|
|
411
|
+
return null;
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function normalizeConfig(config) {
|
|
415
|
+
if (config === null ||
|
|
416
|
+
!isNonEmptyString(config.runId) ||
|
|
417
|
+
!isNonEmptyString(config.sourcePropertyId) ||
|
|
418
|
+
(config.projectionPropertyId !== undefined && !isNonEmptyString(config.projectionPropertyId)) ||
|
|
419
|
+
(config.sourceDeviceId !== undefined && !isNonEmptyString(config.sourceDeviceId)) ||
|
|
420
|
+
(config.exportPath !== undefined && !isNonEmptyString(config.exportPath))) {
|
|
421
|
+
return null;
|
|
422
|
+
}
|
|
423
|
+
const captureDurationMs = config.captureDurationMs ?? MAX_CAPTURE_DURATION_MS;
|
|
424
|
+
const maxRecords = config.maxRecords ?? MAX_CAPTURE_RECORDS;
|
|
425
|
+
if (!Number.isInteger(captureDurationMs) ||
|
|
426
|
+
captureDurationMs <= 0 ||
|
|
427
|
+
captureDurationMs > MAX_CAPTURE_DURATION_MS ||
|
|
428
|
+
!Number.isInteger(maxRecords) ||
|
|
429
|
+
maxRecords <= 0 ||
|
|
430
|
+
maxRecords > MAX_CAPTURE_RECORDS) {
|
|
431
|
+
return null;
|
|
432
|
+
}
|
|
433
|
+
return Object.freeze({ ...config, captureDurationMs, maxRecords });
|
|
434
|
+
}
|
|
435
|
+
function isNonEmptyString(value) {
|
|
436
|
+
return typeof value === 'string' && value.trim().length > 0;
|
|
437
|
+
}
|
|
438
|
+
//# sourceMappingURL=command-latency-trace-collector.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"command-latency-trace-collector.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/command-latency-trace-collector.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqD;AACrD,6CAAqD;AACrD,qCAAuC;AACvC,+CAA8C;AAC9C,qDAA8C;AAE9C,2CAA+E;AAqBlE,QAAA,6BAA6B,GAAG,MAAM,CAAC,+BAA+B,CAAC,CAAC;AAoFrF,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACv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K,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC;AAC7D,CAAC"}
|
|
@@ -2,6 +2,7 @@ import { PropertyValueState } from '../models/property-value-state.model';
|
|
|
2
2
|
import { IDevicePropertyData } from '../platforms/device.platform';
|
|
3
3
|
import { ChannelsPropertiesService } from './channels.properties.service';
|
|
4
4
|
import { ChannelsService } from './channels.service';
|
|
5
|
+
import { CommandLatencyTraceCollectorService } from './command-latency-trace-collector.service';
|
|
5
6
|
import { DeviceStructureLockService } from './device-structure-lock.service';
|
|
6
7
|
import { DevicesService } from './devices.service';
|
|
7
8
|
import { PlatformRegistryService } from './platform.registry.service';
|
|
@@ -33,7 +34,8 @@ export declare class PropertyCommandDispatchService {
|
|
|
33
34
|
private readonly structureLock;
|
|
34
35
|
private readonly propertyStateCoordinator;
|
|
35
36
|
private readonly commandWindowService;
|
|
36
|
-
|
|
37
|
+
private readonly commandLatencyTraceCollector;
|
|
38
|
+
constructor(channelsPropertiesService: ChannelsPropertiesService, channelsService: ChannelsService, devicesService: DevicesService, platformRegistryService: PlatformRegistryService, valueSourceRegistry: PropertyValueSourceRegistryService, structureLock: DeviceStructureLockService, propertyStateCoordinator: PropertyStateCoordinatorService, commandWindowService: PropertyCommandWindowService, commandLatencyTraceCollector?: CommandLatencyTraceCollectorService);
|
|
37
39
|
dispatchBatch(updates: readonly IDevicePropertyData[], options?: PropertyCommandDispatchOptions): Promise<PropertyCommandDispatchResult>;
|
|
38
40
|
prepareApiCommand(update: IDevicePropertyData, ttlMs: number): Promise<PreparedApiPropertyCommand | null>;
|
|
39
41
|
private admitWindows;
|
|
@@ -8,6 +8,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
8
8
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
11
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
15
|
exports.PropertyCommandDispatchService = void 0;
|
|
13
16
|
const common_1 = require("@nestjs/common");
|
|
@@ -16,6 +19,7 @@ const property_value_state_model_1 = require("../models/property-value-state.mod
|
|
|
16
19
|
const property_command_value_utils_1 = require("../utils/property-command-value.utils");
|
|
17
20
|
const channels_properties_service_1 = require("./channels.properties.service");
|
|
18
21
|
const channels_service_1 = require("./channels.service");
|
|
22
|
+
const command_latency_trace_collector_service_1 = require("./command-latency-trace-collector.service");
|
|
19
23
|
const device_structure_lock_service_1 = require("./device-structure-lock.service");
|
|
20
24
|
const devices_service_1 = require("./devices.service");
|
|
21
25
|
const platform_registry_service_1 = require("./platform.registry.service");
|
|
@@ -23,7 +27,7 @@ const property_command_window_service_1 = require("./property-command-window.ser
|
|
|
23
27
|
const property_state_coordinator_service_1 = require("./property-state-coordinator.service");
|
|
24
28
|
const property_value_source_registry_service_1 = require("./property-value-source.registry.service");
|
|
25
29
|
let PropertyCommandDispatchService = class PropertyCommandDispatchService {
|
|
26
|
-
constructor(channelsPropertiesService, channelsService, devicesService, platformRegistryService, valueSourceRegistry, structureLock, propertyStateCoordinator, commandWindowService) {
|
|
30
|
+
constructor(channelsPropertiesService, channelsService, devicesService, platformRegistryService, valueSourceRegistry, structureLock, propertyStateCoordinator, commandWindowService, commandLatencyTraceCollector = new command_latency_trace_collector_service_1.CommandLatencyTraceCollectorService()) {
|
|
27
31
|
this.channelsPropertiesService = channelsPropertiesService;
|
|
28
32
|
this.channelsService = channelsService;
|
|
29
33
|
this.devicesService = devicesService;
|
|
@@ -32,6 +36,7 @@ let PropertyCommandDispatchService = class PropertyCommandDispatchService {
|
|
|
32
36
|
this.structureLock = structureLock;
|
|
33
37
|
this.propertyStateCoordinator = propertyStateCoordinator;
|
|
34
38
|
this.commandWindowService = commandWindowService;
|
|
39
|
+
this.commandLatencyTraceCollector = commandLatencyTraceCollector;
|
|
35
40
|
}
|
|
36
41
|
async dispatchBatch(updates, options = {}) {
|
|
37
42
|
if (updates.length === 0) {
|
|
@@ -94,15 +99,17 @@ let PropertyCommandDispatchService = class PropertyCommandDispatchService {
|
|
|
94
99
|
if (!admission.eligible) {
|
|
95
100
|
continue;
|
|
96
101
|
}
|
|
102
|
+
const handle = this.commandWindowService.open({
|
|
103
|
+
canonicalTarget: admission.canonicalTarget,
|
|
104
|
+
requestedTargets: admission.requestedTargets,
|
|
105
|
+
intentId: options.intentId,
|
|
106
|
+
commandedValue: admission.commandedValue,
|
|
107
|
+
previousValue: admission.previousValue,
|
|
108
|
+
ttlMs: options.ttlMs ?? 3_000,
|
|
109
|
+
});
|
|
110
|
+
this.commandLatencyTraceCollector.bindWindow(options.intentId, admission.canonicalPropertyId, handle.generation);
|
|
97
111
|
admitted.push({
|
|
98
|
-
handle
|
|
99
|
-
canonicalTarget: admission.canonicalTarget,
|
|
100
|
-
requestedTargets: admission.requestedTargets,
|
|
101
|
-
intentId: options.intentId,
|
|
102
|
-
commandedValue: admission.commandedValue,
|
|
103
|
-
previousValue: admission.previousValue,
|
|
104
|
-
ttlMs: options.ttlMs ?? 3_000,
|
|
105
|
-
}),
|
|
112
|
+
handle,
|
|
106
113
|
admission,
|
|
107
114
|
});
|
|
108
115
|
}
|
|
@@ -200,6 +207,7 @@ let PropertyCommandDispatchService = class PropertyCommandDispatchService {
|
|
|
200
207
|
exports.PropertyCommandDispatchService = PropertyCommandDispatchService;
|
|
201
208
|
exports.PropertyCommandDispatchService = PropertyCommandDispatchService = __decorate([
|
|
202
209
|
(0, common_1.Injectable)(),
|
|
210
|
+
__param(8, (0, common_1.Optional)()),
|
|
203
211
|
__metadata("design:paramtypes", [channels_properties_service_1.ChannelsPropertiesService,
|
|
204
212
|
channels_service_1.ChannelsService,
|
|
205
213
|
devices_service_1.DevicesService,
|
|
@@ -207,7 +215,8 @@ exports.PropertyCommandDispatchService = PropertyCommandDispatchService = __deco
|
|
|
207
215
|
property_value_source_registry_service_1.PropertyValueSourceRegistryService,
|
|
208
216
|
device_structure_lock_service_1.DeviceStructureLockService,
|
|
209
217
|
property_state_coordinator_service_1.PropertyStateCoordinatorService,
|
|
210
|
-
property_command_window_service_1.PropertyCommandWindowService
|
|
218
|
+
property_command_window_service_1.PropertyCommandWindowService,
|
|
219
|
+
command_latency_trace_collector_service_1.CommandLatencyTraceCollectorService])
|
|
211
220
|
], PropertyCommandDispatchService);
|
|
212
221
|
const getEntityId = (entity) => typeof entity === 'string' ? entity : (entity?.id ?? null);
|
|
213
222
|
const toTarget = ({ device, channel, property, }) => ({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"property-command-dispatch.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/property-command-dispatch.service.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"property-command-dispatch.service.js","sourceRoot":"","sources":["../../../../src/modules/devices/services/property-command-dispatch.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsD;AAEtD,4DAAsD;AACtD,qFAA0E;AAE1E,wFAA2G;AAE3G,+EAA0E;AAC1E,yDAAqD;AACrD,uGAAgG;AAChG,mFAA6E;AAC7E,uDAAmD;AACnD,2EAAsE;AACtE,uFAI2C;AAC3C,6FAAuF;AACvF,qGAA8F;AA6CvF,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IAC1C,YACkB,yBAAoD,EACpD,eAAgC,EAChC,cAA8B,EAC9B,uBAAgD,EAChD,mBAAuD,EACvD,aAAyC,EACzC,wBAAyD,EACzD,oBAAkD,EAElD,+BAAoE,IAAI,6EAAmC,EAAE;QAT7G,8BAAyB,GAAzB,yBAAyB,CAA2B;QACpD,oBAAe,GAAf,eAAe,CAAiB;QAChC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,4BAAuB,GAAvB,uBAAuB,CAAyB;QAChD,wBAAmB,GAAnB,mB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AuB;QAC3B,2EAAkC;QACxC,0DAA0B;QACf,oEAA+B;QACnC,8DAA4B;QAEpB,6EAAmC;GAXvE,8BAA8B,CAoQ1C;AAED,MAAM,WAAW,GAAG,CAA2B,MAAqC,EAAiB,EAAE,CACtG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,IAAI,IAAI,CAAC,CAAC;AAE5D,MAAM,QAAQ,GAAG,CAAC,EACjB,MAAM,EACN,OAAO,EACP,QAAQ,GACsD,EAA+B,EAAE,CAAC,CAAC;IACjG,QAAQ,EAAE,MAAM,CAAC,EAAE;IACnB,SAAS,EAAE,OAAO,CAAC,EAAE;IACrB,UAAU,EAAE,QAAQ,CAAC,EAAE;CACvB,CAAC,CAAC"}
|
|
@@ -50,6 +50,7 @@ export declare class PropertyCommandWindowService {
|
|
|
50
50
|
private readonly recoveries;
|
|
51
51
|
open(input: OpenPropertyCommandWindowInput): PropertyCommandWindowHandle;
|
|
52
52
|
get(canonicalPropertyId: string): PropertyCommandWindow | null;
|
|
53
|
+
peekGeneration(canonicalPropertyId: string): string | undefined;
|
|
53
54
|
confirm(handle: PropertyCommandWindowHandle, receipt: PropertyCommandReceipt): PropertyCommandWindow | null;
|
|
54
55
|
attachPatchReceipt(handle: PropertyCommandWindowHandle, receipt: PropertyCommandPatchReceipt): boolean;
|
|
55
56
|
hold(handle: PropertyCommandWindowHandle, receipt: PropertyCommandReceipt): PropertyCommandWindow | null;
|
|
@@ -47,6 +47,10 @@ let PropertyCommandWindowService = class PropertyCommandWindowService {
|
|
|
47
47
|
get(canonicalPropertyId) {
|
|
48
48
|
return this.toSnapshot(this.getCurrent(canonicalPropertyId, Date.now()));
|
|
49
49
|
}
|
|
50
|
+
peekGeneration(canonicalPropertyId) {
|
|
51
|
+
const current = this.windows.get(canonicalPropertyId);
|
|
52
|
+
return current !== undefined && current.expiresAt > Date.now() ? current.generation : undefined;
|
|
53
|
+
}
|
|
50
54
|
confirm(handle, receipt) {
|
|
51
55
|
const current = this.getCurrent(handle.canonicalPropertyId, Date.now());
|
|
52
56
|
if (current === undefined || current.generation !== handle.generation) {
|