mirror of https://github.com/grpc/grpc-node.git
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:
commit
798283e641
|
|
@ -105,6 +105,7 @@ export class XdsClient {
|
||||||
> = new Map<string, Watcher<ClusterLoadAssignment__Output>[]>();
|
> = new Map<string, Watcher<ClusterLoadAssignment__Output>[]>();
|
||||||
private lastEdsVersionInfo = '';
|
private lastEdsVersionInfo = '';
|
||||||
private lastEdsNonce = '';
|
private lastEdsNonce = '';
|
||||||
|
private latestEdsResponses: ClusterLoadAssignment__Output[] = [];
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private targetName: string,
|
private targetName: string,
|
||||||
|
|
@ -206,6 +207,7 @@ export class XdsClient {
|
||||||
}
|
}
|
||||||
this.lastEdsVersionInfo = message.version_info;
|
this.lastEdsVersionInfo = message.version_info;
|
||||||
this.lastEdsNonce = message.nonce;
|
this.lastEdsNonce = message.nonce;
|
||||||
|
this.latestEdsResponses = edsResponses;
|
||||||
this.ackEds();
|
this.ackEds();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
@ -357,6 +359,18 @@ export class XdsClient {
|
||||||
if (addedServiceName) {
|
if (addedServiceName) {
|
||||||
this.updateEdsNames();
|
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(
|
removeEndpointWatcher(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue