mirror of https://github.com/grpc/grpc-node.git
grpc-js: Make a reachable code path for requestReresolution in pick_first
This commit is contained in:
parent
478900d191
commit
8cbc3dc825
|
@ -184,8 +184,10 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
) {
|
) {
|
||||||
/* If all of the subchannels are IDLE we should go back to a
|
/* If all of the subchannels are IDLE we should go back to a
|
||||||
* basic IDLE state where there is no subchannel list to avoid
|
* basic IDLE state where there is no subchannel list to avoid
|
||||||
* holding unused resources */
|
* holding unused resources. We do not reset triedAllSubchannels
|
||||||
this.resetSubchannelList();
|
* because that is a reminder to request reresolution the next time
|
||||||
|
* this LB policy needs to connect. */
|
||||||
|
this.resetSubchannelList(false);
|
||||||
this.updateState(ConnectivityState.IDLE, new QueuePicker(this));
|
this.updateState(ConnectivityState.IDLE, new QueuePicker(this));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -337,7 +339,7 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
this.channelControlHelper.updateState(newState, picker);
|
this.channelControlHelper.updateState(newState, picker);
|
||||||
}
|
}
|
||||||
|
|
||||||
private resetSubchannelList() {
|
private resetSubchannelList(resetTriedAllSubchannels = true) {
|
||||||
for (const subchannel of this.subchannels) {
|
for (const subchannel of this.subchannels) {
|
||||||
subchannel.removeConnectivityStateListener(this.subchannelStateListener);
|
subchannel.removeConnectivityStateListener(this.subchannelStateListener);
|
||||||
subchannel.unref();
|
subchannel.unref();
|
||||||
|
@ -352,7 +354,9 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
[ConnectivityState.TRANSIENT_FAILURE]: 0,
|
[ConnectivityState.TRANSIENT_FAILURE]: 0,
|
||||||
};
|
};
|
||||||
this.subchannels = [];
|
this.subchannels = [];
|
||||||
this.triedAllSubchannels = false;
|
if (resetTriedAllSubchannels) {
|
||||||
|
this.triedAllSubchannels = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -425,6 +429,12 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
}
|
}
|
||||||
|
|
||||||
exitIdle() {
|
exitIdle() {
|
||||||
|
if (
|
||||||
|
this.currentState === ConnectivityState.IDLE ||
|
||||||
|
this.triedAllSubchannels
|
||||||
|
) {
|
||||||
|
this.channelControlHelper.requestReresolution();
|
||||||
|
}
|
||||||
for (const subchannel of this.subchannels) {
|
for (const subchannel of this.subchannels) {
|
||||||
subchannel.startConnecting();
|
subchannel.startConnecting();
|
||||||
}
|
}
|
||||||
|
@ -433,12 +443,6 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
this.connectToAddressList();
|
this.connectToAddressList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (
|
|
||||||
this.currentState === ConnectivityState.IDLE ||
|
|
||||||
this.triedAllSubchannels
|
|
||||||
) {
|
|
||||||
this.channelControlHelper.requestReresolution();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
resetBackoff() {
|
resetBackoff() {
|
||||||
|
|
Loading…
Reference in New Issue