@grpc/grpc-js
Advanced tools
Comparing version 1.10.10 to 1.10.11
import { ChannelCredentials } from './channel-credentials'; | ||
import { ChannelOptions } from './channel-options'; | ||
import { PickResult } from './picker'; | ||
import { Metadata } from './metadata'; | ||
@@ -99,3 +100,3 @@ import { CallConfig } from './resolver'; | ||
[key: string]: string; | ||
}): import("./picker").PickResult; | ||
}): PickResult; | ||
queueCallForPick(call: LoadBalancingCall): void; | ||
@@ -102,0 +103,0 @@ getConfig(method: string, metadata: Metadata): GetConfigResult; |
@@ -24,2 +24,3 @@ "use strict"; | ||
const picker_1 = require("./picker"); | ||
const metadata_1 = require("./metadata"); | ||
const constants_1 = require("./constants"); | ||
@@ -74,2 +75,17 @@ const filter_stack_1 = require("./filter-stack"); | ||
} | ||
class ShutdownPicker { | ||
pick(pickArgs) { | ||
return { | ||
pickResultType: picker_1.PickResultType.DROP, | ||
status: { | ||
code: constants_1.Status.UNAVAILABLE, | ||
details: 'Channel closed before call started', | ||
metadata: new metadata_1.Metadata() | ||
}, | ||
subchannel: null, | ||
onCallStarted: null, | ||
onCallEnded: null | ||
}; | ||
} | ||
} | ||
class InternalChannel { | ||
@@ -345,3 +361,5 @@ constructor(target, credentials, options) { | ||
getConfig(method, metadata) { | ||
this.resolvingLoadBalancer.exitIdle(); | ||
if (this.connectivityState !== connectivity_state_1.ConnectivityState.SHUTDOWN) { | ||
this.resolvingLoadBalancer.exitIdle(); | ||
} | ||
if (this.configSelector) { | ||
@@ -476,2 +494,11 @@ return { | ||
this.updateState(connectivity_state_1.ConnectivityState.SHUTDOWN); | ||
this.currentPicker = new ShutdownPicker(); | ||
for (const call of this.configSelectionQueue) { | ||
call.cancelWithStatus(constants_1.Status.UNAVAILABLE, 'Channel closed before call started'); | ||
} | ||
this.configSelectionQueue = []; | ||
for (const call of this.pickQueue) { | ||
call.cancelWithStatus(constants_1.Status.UNAVAILABLE, 'Channel closed before call started'); | ||
} | ||
this.pickQueue = []; | ||
clearInterval(this.callRefTimer); | ||
@@ -478,0 +505,0 @@ if (this.idleTimer) { |
@@ -23,5 +23,6 @@ "use strict"; | ||
const picker_1 = require("./picker"); | ||
const subchannel_address_1 = require("./subchannel-address"); | ||
const logging = require("./logging"); | ||
const constants_1 = require("./constants"); | ||
const subchannel_address_1 = require("./subchannel-address"); | ||
const subchannel_address_2 = require("./subchannel-address"); | ||
const net_1 = require("net"); | ||
@@ -108,5 +109,5 @@ const TRACER_NAME = 'pick_first'; | ||
const ipv4Addresses = []; | ||
const ipv6First = (0, subchannel_address_1.isTcpSubchannelAddress)(addressList[0]) && (0, net_1.isIPv6)(addressList[0].host); | ||
const ipv6First = (0, subchannel_address_2.isTcpSubchannelAddress)(addressList[0]) && (0, net_1.isIPv6)(addressList[0].host); | ||
for (const address of addressList) { | ||
if ((0, subchannel_address_1.isTcpSubchannelAddress)(address) && (0, net_1.isIPv6)(address.host)) { | ||
if ((0, subchannel_address_2.isTcpSubchannelAddress)(address) && (0, net_1.isIPv6)(address.host)) { | ||
ipv6Addresses.push(address); | ||
@@ -267,3 +268,2 @@ } | ||
this.calculateAndReportNewState(); | ||
this.requestReresolution(); | ||
} | ||
@@ -383,2 +383,11 @@ return; | ||
})); | ||
trace('connectToAddressList([' + addressList.map(address => (0, subchannel_address_1.subchannelAddressToString)(address)) + '])'); | ||
for (const { subchannel } of newChildrenList) { | ||
if (subchannel.getConnectivityState() === connectivity_state_1.ConnectivityState.READY) { | ||
this.channelControlHelper.addChannelzChild(subchannel.getChannelzRef()); | ||
subchannel.addConnectivityStateListener(this.subchannelStateListener); | ||
this.pickSubchannel(subchannel); | ||
return; | ||
} | ||
} | ||
/* Ref each subchannel before resetting the list, to ensure that | ||
@@ -395,6 +404,2 @@ * subchannels shared between the list don't drop to 0 refs during the | ||
subchannel.addConnectivityStateListener(this.subchannelStateListener); | ||
if (subchannel.getConnectivityState() === connectivity_state_1.ConnectivityState.READY) { | ||
this.pickSubchannel(subchannel); | ||
return; | ||
} | ||
} | ||
@@ -421,2 +426,3 @@ for (const child of this.children) { | ||
const rawAddressList = [].concat(...endpointList.map(endpoint => endpoint.addresses)); | ||
trace('updateAddressList([' + rawAddressList.map(address => (0, subchannel_address_1.subchannelAddressToString)(address)) + '])'); | ||
if (rawAddressList.length === 0) { | ||
@@ -423,0 +429,0 @@ throw new Error('No addresses in endpoint list passed to pick_first'); |
{ | ||
"name": "@grpc/grpc-js", | ||
"version": "1.10.10", | ||
"version": "1.10.11", | ||
"description": "gRPC Library for Node - pure JS implementation", | ||
@@ -5,0 +5,0 @@ "homepage": "https://grpc.io/", |
@@ -23,3 +23,3 @@ /* | ||
import { ChannelControlHelper } from './load-balancer'; | ||
import { UnavailablePicker, Picker, QueuePicker } from './picker'; | ||
import { UnavailablePicker, Picker, QueuePicker, PickArgs, PickResult, PickResultType } from './picker'; | ||
import { Metadata } from './metadata'; | ||
@@ -147,2 +147,18 @@ import { Status, LogVerbosity, Propagate } from './constants'; | ||
class ShutdownPicker implements Picker { | ||
pick(pickArgs: PickArgs): PickResult { | ||
return { | ||
pickResultType: PickResultType.DROP, | ||
status: { | ||
code: Status.UNAVAILABLE, | ||
details: 'Channel closed before call started', | ||
metadata: new Metadata() | ||
}, | ||
subchannel: null, | ||
onCallStarted: null, | ||
onCallEnded: null | ||
} | ||
} | ||
} | ||
export class InternalChannel { | ||
@@ -541,3 +557,5 @@ private readonly resolvingLoadBalancer: ResolvingLoadBalancer; | ||
getConfig(method: string, metadata: Metadata): GetConfigResult { | ||
this.resolvingLoadBalancer.exitIdle(); | ||
if (this.connectivityState !== ConnectivityState.SHUTDOWN) { | ||
this.resolvingLoadBalancer.exitIdle(); | ||
} | ||
if (this.configSelector) { | ||
@@ -751,2 +769,11 @@ return { | ||
this.updateState(ConnectivityState.SHUTDOWN); | ||
this.currentPicker = new ShutdownPicker(); | ||
for (const call of this.configSelectionQueue) { | ||
call.cancelWithStatus(Status.UNAVAILABLE, 'Channel closed before call started'); | ||
} | ||
this.configSelectionQueue = []; | ||
for (const call of this.pickQueue) { | ||
call.cancelWithStatus(Status.UNAVAILABLE, 'Channel closed before call started'); | ||
} | ||
this.pickQueue = []; | ||
clearInterval(this.callRefTimer); | ||
@@ -753,0 +780,0 @@ if (this.idleTimer) { |
@@ -35,3 +35,3 @@ /* | ||
} from './picker'; | ||
import { Endpoint, SubchannelAddress } from './subchannel-address'; | ||
import { Endpoint, SubchannelAddress, subchannelAddressToString } from './subchannel-address'; | ||
import * as logging from './logging'; | ||
@@ -352,3 +352,2 @@ import { LogVerbosity } from './constants'; | ||
this.calculateAndReportNewState(); | ||
this.requestReresolution(); | ||
} | ||
@@ -488,2 +487,11 @@ return; | ||
})); | ||
trace('connectToAddressList([' + addressList.map(address => subchannelAddressToString(address)) + '])'); | ||
for (const { subchannel } of newChildrenList) { | ||
if (subchannel.getConnectivityState() === ConnectivityState.READY) { | ||
this.channelControlHelper.addChannelzChild(subchannel.getChannelzRef()); | ||
subchannel.addConnectivityStateListener(this.subchannelStateListener); | ||
this.pickSubchannel(subchannel); | ||
return; | ||
} | ||
} | ||
/* Ref each subchannel before resetting the list, to ensure that | ||
@@ -500,6 +508,2 @@ * subchannels shared between the list don't drop to 0 refs during the | ||
subchannel.addConnectivityStateListener(this.subchannelStateListener); | ||
if (subchannel.getConnectivityState() === ConnectivityState.READY) { | ||
this.pickSubchannel(subchannel); | ||
return; | ||
} | ||
} | ||
@@ -534,2 +538,3 @@ for (const child of this.children) { | ||
); | ||
trace('updateAddressList([' + rawAddressList.map(address => subchannelAddressToString(address)) + '])'); | ||
if (rawAddressList.length === 0) { | ||
@@ -536,0 +541,0 @@ throw new Error('No addresses in endpoint list passed to pick_first'); |
@@ -1793,15 +1793,18 @@ /* | ||
sessionInfo !== undefined && | ||
sessionInfo.activeStreams === 0 && | ||
Date.now() - sessionInfo.lastIdle >= ctx.sessionIdleTimeout | ||
sessionInfo.activeStreams === 0 | ||
) { | ||
ctx.trace( | ||
'Session idle timeout triggered for ' + | ||
socket?.remoteAddress + | ||
':' + | ||
socket?.remotePort + | ||
' last idle at ' + | ||
sessionInfo.lastIdle | ||
); | ||
if (Date.now() - sessionInfo.lastIdle >= ctx.sessionIdleTimeout) { | ||
ctx.trace( | ||
'Session idle timeout triggered for ' + | ||
socket?.remoteAddress + | ||
':' + | ||
socket?.remotePort + | ||
' last idle at ' + | ||
sessionInfo.lastIdle | ||
); | ||
ctx.closeSession(session); | ||
ctx.closeSession(session); | ||
} else { | ||
sessionInfo.timeout.refresh(); | ||
} | ||
} | ||
@@ -1808,0 +1811,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1862324
38115