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>[]>();
|
||||
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(
|
||||
|
|
|
|||
Loading…
Reference in New Issue