[Telemetry Collections] Add process method to historical request options (for yield requests) (#4201)

* added processor generator to request options in the telemetry API. Allows progressive yielding of request results.

Co-authored-by: Andrew Henry <akhenry@gmail.com>
This commit is contained in:
Jamie V 2021-09-17 17:50:53 -07:00 committed by GitHub
parent dad9f12a5c
commit e56c673005
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -115,6 +115,7 @@ export class TelemetryCollection extends EventEmitter {
this._requestHistoricalTelemetry();
}
/**
* If a historical provider exists, then historical requests will be made
* @private
@ -126,20 +127,25 @@ export class TelemetryCollection extends EventEmitter {
let historicalData;
this.options.onPartialResponse = this._processNewTelemetry.bind(this);
try {
this.requestAbort = new AbortController();
this.options.signal = this.requestAbort.signal;
historicalData = await this.historicalProvider.request(this.domainObject, this.options);
this.requestAbort = undefined;
} catch (error) {
console.error('Error requesting telemetry data...');
this.requestAbort = undefined;
this._error(error);
if (error.name !== 'AbortError') {
console.error('Error requesting telemetry data...');
this._error(error);
}
}
this.requestAbort = undefined;
this._processNewTelemetry(historicalData);
}
/**
* This uses the built in subscription function from Telemetry API
* @private