get rid of batch for now

This commit is contained in:
Scott Bell 2024-08-15 15:45:09 -05:00
parent df3ca84fda
commit 484a81b370

View File

@ -7,9 +7,6 @@ export default class CompsManager extends EventEmitter {
#telemetryObjects = {}; #telemetryObjects = {};
#telemetryCollections = {}; #telemetryCollections = {};
#dataFrame = {}; #dataFrame = {};
#batchedNewData = {};
#batchPromises = {};
#BATCH_DEBOUNCE_MS = 1;
#telemetryLoadedPromises = []; #telemetryLoadedPromises = [];
constructor(openmct, domainObject) { constructor(openmct, domainObject) {
@ -158,39 +155,8 @@ export default class CompsManager extends EventEmitter {
return underlyingTelemetry; return underlyingTelemetry;
} }
#clearBatch(keyString) { #telemetryProcessor = (newTelemetry, keyString) => {
this.#batchedNewData[keyString] = []; this.emit('underlyingTelemetryUpdated', { [keyString]: newTelemetry });
this.#batchPromises[keyString] = null;
}
#deferredTelemetryProcessor(newTelemetry, keyString) {
// We until the next event loop cycle to "collect" all of the get
// requests triggered in this iteration of the event loop
if (!this.#batchedNewData[keyString]) {
this.#batchedNewData[keyString] = [];
}
this.#batchedNewData[keyString].push(newTelemetry[0]);
if (!this.#batchPromises[keyString]) {
this.#batchPromises[keyString] = [];
this.#batchPromises[keyString] = this.#batchedTelemetryProcessor(
this.#batchedNewData[keyString],
keyString
);
}
}
#batchedTelemetryProcessor = async (newTelemetry, keyString) => {
await this.#waitForDebounce();
const specificBatchedNewData = this.#batchedNewData[keyString];
// clear it
this.#clearBatch(keyString);
this.emit('underlyingTelemetryUpdated', { [keyString]: specificBatchedNewData });
}; };
#clearData() { #clearData() {
@ -201,17 +167,6 @@ export default class CompsManager extends EventEmitter {
return this.#domainObject.configuration.comps.expression; return this.#domainObject.configuration.comps.expression;
} }
#waitForDebounce() {
let timeoutID;
clearTimeout(timeoutID);
return new Promise((resolve) => {
timeoutID = setTimeout(() => {
resolve();
}, this.#BATCH_DEBOUNCE_MS);
});
}
#addTelemetryObject = (telemetryObject) => { #addTelemetryObject = (telemetryObject) => {
const keyString = this.#openmct.objects.makeKeyString(telemetryObject.identifier); const keyString = this.#openmct.objects.makeKeyString(telemetryObject.identifier);
this.#telemetryObjects[keyString] = telemetryObject; this.#telemetryObjects[keyString] = telemetryObject;
@ -219,7 +174,7 @@ export default class CompsManager extends EventEmitter {
this.#openmct.telemetry.requestCollection(telemetryObject); this.#openmct.telemetry.requestCollection(telemetryObject);
this.#telemetryCollections[keyString].on('add', (data) => { this.#telemetryCollections[keyString].on('add', (data) => {
this.#deferredTelemetryProcessor(data, keyString); this.#telemetryProcessor(data, keyString);
}); });
this.#telemetryCollections[keyString].on('clear', this.#clearData); this.#telemetryCollections[keyString].on('clear', this.#clearData);
const telemetryLoadedPromise = this.#telemetryCollections[keyString].load(); const telemetryLoadedPromise = this.#telemetryCollections[keyString].load();