@grpc/grpc-js
Advanced tools
Comparing version
@@ -29,4 +29,4 @@ import { ChannelCredentials } from './channel-credentials'; | ||
private channel; | ||
private stateListeners; | ||
private refCount; | ||
private subchannelStateListener; | ||
constructor(childSubchannel: SubchannelInterface, channel: InternalChannel); | ||
@@ -33,0 +33,0 @@ ref(): void; |
@@ -52,10 +52,7 @@ "use strict"; | ||
this.channel = channel; | ||
this.stateListeners = []; | ||
this.refCount = 0; | ||
childSubchannel.addConnectivityStateListener((subchannel, previousState, newState, keepaliveTime) => { | ||
this.subchannelStateListener = (subchannel, previousState, newState, keepaliveTime) => { | ||
channel.throttleKeepalive(keepaliveTime); | ||
for (const listener of this.stateListeners) { | ||
listener(this, previousState, newState, keepaliveTime); | ||
} | ||
}); | ||
}; | ||
childSubchannel.addConnectivityStateListener(this.subchannelStateListener); | ||
} | ||
@@ -70,2 +67,3 @@ ref() { | ||
if (this.refCount <= 0) { | ||
this.child.removeConnectivityStateListener(this.subchannelStateListener); | ||
this.channel.removeWrappedSubchannel(this); | ||
@@ -72,0 +70,0 @@ } |
@@ -119,3 +119,3 @@ "use strict"; | ||
* delay timer. */ | ||
if (subchannel === this.subchannels[this.currentSubchannelIndex] && | ||
if (subchannel.getRealSubchannel() === this.subchannels[this.currentSubchannelIndex].getRealSubchannel() && | ||
newState === connectivity_state_1.ConnectivityState.TRANSIENT_FAILURE) { | ||
@@ -330,3 +330,3 @@ this.startNextSubchannelConnecting(); | ||
if (this.subchannels.length === 0 || | ||
!this.latestAddressList.every((value, index) => addressList[index] === value)) { | ||
!this.latestAddressList.every((value, index) => (0, subchannel_address_1.subchannelAddressEqual)(addressList[index], value))) { | ||
this.latestAddressList = addressList; | ||
@@ -333,0 +333,0 @@ this.connectToAddressList(); |
{ | ||
"name": "@grpc/grpc-js", | ||
"version": "1.8.9", | ||
"version": "1.8.10", | ||
"description": "gRPC Library for Node - pure JS implementation", | ||
@@ -5,0 +5,0 @@ "homepage": "https://grpc.io/", |
@@ -89,12 +89,10 @@ /* | ||
class ChannelSubchannelWrapper extends BaseSubchannelWrapper implements SubchannelInterface { | ||
private stateListeners: ConnectivityStateListener[] = []; | ||
private refCount = 0; | ||
private subchannelStateListener: ConnectivityStateListener; | ||
constructor(childSubchannel: SubchannelInterface, private channel: InternalChannel) { | ||
super(childSubchannel); | ||
childSubchannel.addConnectivityStateListener((subchannel, previousState, newState, keepaliveTime) => { | ||
this.subchannelStateListener = (subchannel, previousState, newState, keepaliveTime) => { | ||
channel.throttleKeepalive(keepaliveTime); | ||
for (const listener of this.stateListeners) { | ||
listener(this, previousState, newState, keepaliveTime); | ||
} | ||
}); | ||
}; | ||
childSubchannel.addConnectivityStateListener(this.subchannelStateListener); | ||
} | ||
@@ -111,2 +109,3 @@ | ||
if (this.refCount <= 0) { | ||
this.child.removeConnectivityStateListener(this.subchannelStateListener); | ||
this.channel.removeWrappedSubchannel(this); | ||
@@ -113,0 +112,0 @@ } |
@@ -36,2 +36,3 @@ /* | ||
SubchannelAddress, | ||
subchannelAddressEqual, | ||
subchannelAddressToString, | ||
@@ -172,3 +173,3 @@ } from './subchannel-address'; | ||
if ( | ||
subchannel === this.subchannels[this.currentSubchannelIndex] && | ||
subchannel.getRealSubchannel() === this.subchannels[this.currentSubchannelIndex].getRealSubchannel() && | ||
newState === ConnectivityState.TRANSIENT_FAILURE | ||
@@ -425,3 +426,3 @@ ) { | ||
!this.latestAddressList.every( | ||
(value, index) => addressList[index] === value | ||
(value, index) => subchannelAddressEqual(addressList[index], value) | ||
) | ||
@@ -428,0 +429,0 @@ ) { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1694800
0.01%33582
-0.01%