Merge pull request #1511 from murgatroid99/grpc-js_xds_client_response_caching

grpc-js: xDS Client: cache updates to pass them to new watchers
This commit is contained in:
Michael Lumish 2020-07-23 11:18:53 -07:00 committed by GitHub
commit 798283e641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 0 deletions

View File

@ -105,6 +105,7 @@ export class XdsClient {
> = new Map<string, Watcher<ClusterLoadAssignment__Output>[]>();
private lastEdsVersionInfo = '';
private lastEdsNonce = '';
private latestEdsResponses: ClusterLoadAssignment__Output[] = [];
constructor(
private targetName: string,
@ -206,6 +207,7 @@ export class XdsClient {
}
this.lastEdsVersionInfo = message.version_info;
this.lastEdsNonce = message.nonce;
this.latestEdsResponses = edsResponses;
this.ackEds();
break;
}
@ -357,6 +359,18 @@ export class XdsClient {
if (addedServiceName) {
this.updateEdsNames();
}
/* If we have already received an update for the requested edsServiceName,
* immediately pass that update along to the watcher */
for (const message of this.latestEdsResponses) {
if (message.cluster_name === edsServiceName) {
/* These updates normally occur asynchronously, so we ensure that
* the same happens here */
process.nextTick(() => {
watcher.onValidUpdate(message);
});
}
}
}
removeEndpointWatcher(