mirror of https://github.com/grpc/grpc-node.git
Pick first load balancer: don't connect forever without calls
This commit is contained in:
parent
b4d848865d
commit
ee4985886d
|
|
@ -122,19 +122,6 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
if (newState === ConnectivityState.CONNECTING) {
|
if (newState === ConnectivityState.CONNECTING) {
|
||||||
this.subchannelConnectingCount += 1;
|
this.subchannelConnectingCount += 1;
|
||||||
}
|
}
|
||||||
if (newState === ConnectivityState.READY) {
|
|
||||||
this.pickSubchannel(subchannel);
|
|
||||||
return;
|
|
||||||
} else {
|
|
||||||
if (this.currentPick === null) {
|
|
||||||
if (
|
|
||||||
newState === ConnectivityState.TRANSIENT_FAILURE ||
|
|
||||||
newState === ConnectivityState.IDLE
|
|
||||||
) {
|
|
||||||
process.nextTick(() => {
|
|
||||||
subchannel.startConnecting();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/* If the subchannel we most recently attempted to start connecting
|
/* If the subchannel we most recently attempted to start connecting
|
||||||
* to goes into TRANSIENT_FAILURE, immediately try to start
|
* to goes into TRANSIENT_FAILURE, immediately try to start
|
||||||
* connecting to the next one instead of waiting for the connection
|
* connecting to the next one instead of waiting for the connection
|
||||||
|
|
@ -145,6 +132,11 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
) {
|
) {
|
||||||
this.startNextSubchannelConnecting();
|
this.startNextSubchannelConnecting();
|
||||||
}
|
}
|
||||||
|
if (newState === ConnectivityState.READY) {
|
||||||
|
this.pickSubchannel(subchannel);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
if (this.currentPick === null) {
|
||||||
if (this.triedAllSubchannels) {
|
if (this.triedAllSubchannels) {
|
||||||
const newLBState =
|
const newLBState =
|
||||||
this.subchannelConnectingCount > 0
|
this.subchannelConnectingCount > 0
|
||||||
|
|
@ -318,6 +310,9 @@ export class PickFirstLoadBalancer implements LoadBalancer {
|
||||||
}
|
}
|
||||||
|
|
||||||
exitIdle() {
|
exitIdle() {
|
||||||
|
for (const subchannel of this.subchannels) {
|
||||||
|
subchannel.startConnecting();
|
||||||
|
}
|
||||||
if (this.currentState === ConnectivityState.IDLE) {
|
if (this.currentState === ConnectivityState.IDLE) {
|
||||||
if (this.latestAddressList.length > 0) {
|
if (this.latestAddressList.length > 0) {
|
||||||
this.connectToAddressList();
|
this.connectToAddressList();
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue