mirror of https://github.com/grpc/grpc-node.git
grpc-js: Hold a reference to transport in SubchannelCall
This commit is contained in:
parent
0081d24a2c
commit
6d98dc5bbf
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "@grpc/grpc-js",
|
"name": "@grpc/grpc-js",
|
||||||
"version": "1.8.5",
|
"version": "1.8.6",
|
||||||
"description": "gRPC Library for Node - pure JS implementation",
|
"description": "gRPC Library for Node - pure JS implementation",
|
||||||
"homepage": "https://grpc.io/",
|
"homepage": "https://grpc.io/",
|
||||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||||
|
|
|
@ -26,7 +26,7 @@ import { LogVerbosity } from './constants';
|
||||||
import { ServerSurfaceCall } from './server-call';
|
import { ServerSurfaceCall } from './server-call';
|
||||||
import { Deadline } from './deadline';
|
import { Deadline } from './deadline';
|
||||||
import { InterceptingListener, MessageContext, StatusObject, WriteCallback } from './call-interface';
|
import { InterceptingListener, MessageContext, StatusObject, WriteCallback } from './call-interface';
|
||||||
import { CallEventTracker } from './transport';
|
import { CallEventTracker, Transport } from './transport';
|
||||||
|
|
||||||
const TRACER_NAME = 'subchannel_call';
|
const TRACER_NAME = 'subchannel_call';
|
||||||
|
|
||||||
|
@ -105,24 +105,15 @@ export class Http2SubchannelCall implements SubchannelCall {
|
||||||
// This is populated (non-null) if and only if the call has ended
|
// This is populated (non-null) if and only if the call has ended
|
||||||
private finalStatus: StatusObject | null = null;
|
private finalStatus: StatusObject | null = null;
|
||||||
|
|
||||||
private disconnectListener: () => void;
|
|
||||||
|
|
||||||
private internalError: SystemError | null = null;
|
private internalError: SystemError | null = null;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly http2Stream: http2.ClientHttp2Stream,
|
private readonly http2Stream: http2.ClientHttp2Stream,
|
||||||
private readonly callEventTracker: CallEventTracker,
|
private readonly callEventTracker: CallEventTracker,
|
||||||
private readonly listener: SubchannelCallInterceptingListener,
|
private readonly listener: SubchannelCallInterceptingListener,
|
||||||
private readonly peerName: string,
|
private readonly transport: Transport,
|
||||||
private readonly callId: number
|
private readonly callId: number
|
||||||
) {
|
) {
|
||||||
this.disconnectListener = () => {
|
|
||||||
this.endCall({
|
|
||||||
code: Status.UNAVAILABLE,
|
|
||||||
details: 'Connection dropped',
|
|
||||||
metadata: new Metadata(),
|
|
||||||
});
|
|
||||||
};
|
|
||||||
http2Stream.on('response', (headers, flags) => {
|
http2Stream.on('response', (headers, flags) => {
|
||||||
let headersString = '';
|
let headersString = '';
|
||||||
for (const header of Object.keys(headers)) {
|
for (const header of Object.keys(headers)) {
|
||||||
|
@ -475,7 +466,7 @@ export class Http2SubchannelCall implements SubchannelCall {
|
||||||
}
|
}
|
||||||
|
|
||||||
getPeer(): string {
|
getPeer(): string {
|
||||||
return this.peerName;
|
return this.transport.getPeerName();
|
||||||
}
|
}
|
||||||
|
|
||||||
getCallNumber(): number {
|
getCallNumber(): number {
|
||||||
|
|
|
@ -65,6 +65,7 @@ export interface TransportDisconnectListener {
|
||||||
|
|
||||||
export interface Transport {
|
export interface Transport {
|
||||||
getChannelzRef(): SocketRef;
|
getChannelzRef(): SocketRef;
|
||||||
|
getPeerName(): string;
|
||||||
createCall(metadata: Metadata, host: string, method: string, listener: SubchannelCallInterceptingListener, subchannelCallStatsTracker: Partial<CallEventTracker>): SubchannelCall;
|
createCall(metadata: Metadata, host: string, method: string, listener: SubchannelCallInterceptingListener, subchannelCallStatsTracker: Partial<CallEventTracker>): SubchannelCall;
|
||||||
addDisconnectListener(listener: TransportDisconnectListener): void;
|
addDisconnectListener(listener: TransportDisconnectListener): void;
|
||||||
shutdown(): void;
|
shutdown(): void;
|
||||||
|
@ -448,7 +449,7 @@ class Http2Transport implements Transport {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
call = new Http2SubchannelCall(http2Stream, eventTracker, listener, this.subchannelAddressString, getNextCallNumber());
|
call = new Http2SubchannelCall(http2Stream, eventTracker, listener, this, getNextCallNumber());
|
||||||
this.addActiveCall(call);
|
this.addActiveCall(call);
|
||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
|
@ -457,6 +458,10 @@ class Http2Transport implements Transport {
|
||||||
return this.channelzRef;
|
return this.channelzRef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getPeerName() {
|
||||||
|
return this.subchannelAddressString;
|
||||||
|
}
|
||||||
|
|
||||||
shutdown() {
|
shutdown() {
|
||||||
this.session.close();
|
this.session.close();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue