mirror of https://github.com/grpc/grpc-node.git
Handle changing EDS service name, add comments
This commit is contained in:
parent
044da58c76
commit
ef225cba30
|
@ -282,13 +282,30 @@ export class EdsLoadBalancer implements LoadBalancer {
|
|||
this.lastestConfig = lbConfig;
|
||||
this.latestAttributes = attributes;
|
||||
this.xdsClient = attributes.xdsClient;
|
||||
this.edsServiceName = lbConfig.eds.edsServiceName ?? lbConfig.eds.cluster;
|
||||
const newEdsServiceName = lbConfig.eds.edsServiceName ?? lbConfig.eds.cluster;
|
||||
|
||||
/* If the name is changing, disable the old watcher before adding the new
|
||||
* one */
|
||||
if (this.isWatcherActive && this.edsServiceName !== newEdsServiceName) {
|
||||
this.xdsClient.removeEndpointWatcher(this.edsServiceName!, this.watcher);
|
||||
/* Setting isWatcherActive to false here lets us have one code path for
|
||||
* calling addEndpointWatcher */
|
||||
this.isWatcherActive = false;
|
||||
/* If we have a new name, the latestEdsUpdate does not correspond to
|
||||
* the new config, so it is no longer valid */
|
||||
this.latestEdsUpdate = null;
|
||||
}
|
||||
|
||||
this.edsServiceName = newEdsServiceName;
|
||||
|
||||
if (!this.isWatcherActive) {
|
||||
this.xdsClient.addEndpointWatcher(this.edsServiceName, this.watcher);
|
||||
this.isWatcherActive = true;
|
||||
}
|
||||
|
||||
/* If updateAddressList is called after receiving an update and the update
|
||||
* is still valid, we want to update the child config with the information
|
||||
* in the new EdsLoadBalancingConfig. */
|
||||
this.updateChild();
|
||||
}
|
||||
exitIdle(): void {
|
||||
|
|
Loading…
Reference in New Issue