mirror of https://github.com/grpc/grpc-node.git
grpc-js: Enable the noUnusedLocals TypeScript compiler option
This commit is contained in:
parent
45e277547f
commit
713a2c9bd1
|
@ -38,14 +38,6 @@ export type CheckServerIdentityCallback = (
|
|||
cert: PeerCertificate
|
||||
) => Error | undefined;
|
||||
|
||||
function bufferOrNullEqual(buf1: Buffer | null, buf2: Buffer | null) {
|
||||
if (buf1 === null && buf2 === null) {
|
||||
return true;
|
||||
} else {
|
||||
return buf1 !== null && buf2 !== null && buf1.equals(buf2);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Additional peer verification options that can be set when creating
|
||||
* SSL credentials.
|
||||
|
@ -196,7 +188,7 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
|||
private verifyOptions: VerifyOptions
|
||||
) {
|
||||
super();
|
||||
this.connectionOptions = {
|
||||
this.connectionOptions = {
|
||||
secureContext
|
||||
};
|
||||
// Node asserts that this option is a function, so we cannot pass undefined
|
||||
|
@ -225,7 +217,7 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
|||
}
|
||||
if (other instanceof SecureChannelCredentialsImpl) {
|
||||
return (
|
||||
this.secureContext === other.secureContext &&
|
||||
this.secureContext === other.secureContext &&
|
||||
this.verifyOptions.checkServerIdentity === other.verifyOptions.checkServerIdentity
|
||||
);
|
||||
} else {
|
||||
|
|
|
@ -32,7 +32,6 @@ import {
|
|||
import { Status } from './constants';
|
||||
import { Channel } from './channel';
|
||||
import { CallOptions } from './client';
|
||||
import { CallCredentials } from './call-credentials';
|
||||
import { ClientMethodDefinition } from './make-client';
|
||||
import { getErrorMessage } from './error';
|
||||
|
||||
|
|
|
@ -282,7 +282,7 @@ export class CompressionFilter extends BaseFilter implements Filter {
|
|||
export class CompressionFilterFactory
|
||||
implements FilterFactory<CompressionFilter> {
|
||||
private sharedFilterConfig: SharedCompressionFilterConfig = {};
|
||||
constructor(private readonly channel: Channel, private readonly options: ChannelOptions) {}
|
||||
constructor(channel: Channel, private readonly options: ChannelOptions) {}
|
||||
createFilter(): CompressionFilter {
|
||||
return new CompressionFilter(this.options, this.sharedFilterConfig);
|
||||
}
|
||||
|
|
|
@ -43,9 +43,7 @@ import {
|
|||
loadPackageDefinition,
|
||||
makeClientConstructor,
|
||||
MethodDefinition,
|
||||
ProtobufTypeDefinition,
|
||||
Serialize,
|
||||
ServiceClientConstructor,
|
||||
ServiceDefinition,
|
||||
} from './make-client';
|
||||
import { Metadata, MetadataOptions, MetadataValue } from './metadata';
|
||||
|
|
|
@ -20,7 +20,7 @@ import { ChannelOptions } from './channel-options';
|
|||
import { ResolvingLoadBalancer } from './resolving-load-balancer';
|
||||
import { SubchannelPool, getSubchannelPool } from './subchannel-pool';
|
||||
import { ChannelControlHelper } from './load-balancer';
|
||||
import { UnavailablePicker, Picker, PickResultType } from './picker';
|
||||
import { UnavailablePicker, Picker } from './picker';
|
||||
import { Metadata } from './metadata';
|
||||
import { Status, LogVerbosity, Propagate } from './constants';
|
||||
import { FilterStackFactory } from './filter-stack';
|
||||
|
@ -31,22 +31,19 @@ import {
|
|||
getDefaultAuthority,
|
||||
mapUriDefaultScheme,
|
||||
} from './resolver';
|
||||
import { trace, log } from './logging';
|
||||
import { trace } from './logging';
|
||||
import { SubchannelAddress } from './subchannel-address';
|
||||
import { MaxMessageSizeFilterFactory } from './max-message-size-filter';
|
||||
import { mapProxyName } from './http_proxy';
|
||||
import { GrpcUri, parseUri, splitHostPort, uriToString } from './uri-parser';
|
||||
import { GrpcUri, parseUri, uriToString } from './uri-parser';
|
||||
import { ServerSurfaceCall } from './server-call';
|
||||
import { Filter } from './filter';
|
||||
|
||||
import { ConnectivityState } from './connectivity-state';
|
||||
import { ChannelInfo, ChannelRef, ChannelzCallTracker, ChannelzChildrenTracker, ChannelzTrace, registerChannelzChannel, SubchannelRef, unregisterChannelzRef } from './channelz';
|
||||
import { Subchannel } from './subchannel';
|
||||
import { LoadBalancingCall } from './load-balancing-call';
|
||||
import { CallCredentials } from './call-credentials';
|
||||
import { Call, CallStreamOptions, InterceptingListener, MessageContext, StatusObject } from './call-interface';
|
||||
import { SubchannelCall } from './subchannel-call';
|
||||
import { Deadline, deadlineToString, getDeadlineTimeoutString } from './deadline';
|
||||
import { Call, CallStreamOptions, StatusObject } from './call-interface';
|
||||
import { Deadline, deadlineToString } from './deadline';
|
||||
import { ResolvingCall } from './resolving-call';
|
||||
import { getNextCallNumber } from './call-number';
|
||||
import { restrictControlPlaneStatusCode } from './control-plane-status';
|
||||
|
@ -112,7 +109,7 @@ class ChannelSubchannelWrapper extends BaseSubchannelWrapper implements Subchann
|
|||
}
|
||||
|
||||
export class InternalChannel {
|
||||
|
||||
|
||||
private resolvingLoadBalancer: ResolvingLoadBalancer;
|
||||
private subchannelPool: SubchannelPool;
|
||||
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
|
||||
|
@ -376,7 +373,7 @@ export class InternalChannel {
|
|||
trace(
|
||||
LogVerbosity.DEBUG,
|
||||
'connectivity_state',
|
||||
'(' + this.channelzRef.id + ') ' +
|
||||
'(' + this.channelzRef.id + ') ' +
|
||||
uriToString(this.target) +
|
||||
' ' +
|
||||
ConnectivityState[this.connectivityState] +
|
||||
|
@ -601,7 +598,7 @@ export class InternalChannel {
|
|||
/**
|
||||
* Get the channelz reference object for this channel. The returned value is
|
||||
* garbage if channelz is disabled for this channel.
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
getChannelzRef() {
|
||||
return this.channelzRef;
|
||||
|
|
|
@ -20,11 +20,9 @@ import { ConnectivityState } from "./connectivity-state";
|
|||
import { LogVerbosity, Status } from "./constants";
|
||||
import { durationToMs, isDuration, msToDuration } from "./duration";
|
||||
import { ChannelControlHelper, createChildChannelControlHelper, registerLoadBalancerType } from "./experimental";
|
||||
import { BaseFilter, Filter, FilterFactory } from "./filter";
|
||||
import { getFirstUsableConfig, LoadBalancer, LoadBalancingConfig, validateLoadBalancingConfig } from "./load-balancer";
|
||||
import { ChildLoadBalancerHandler } from "./load-balancer-child-handler";
|
||||
import { PickArgs, Picker, PickResult, PickResultType, QueuePicker, UnavailablePicker } from "./picker";
|
||||
import { Subchannel } from "./subchannel";
|
||||
import { PickArgs, Picker, PickResult, PickResultType } from "./picker";
|
||||
import { SubchannelAddress, subchannelAddressToString } from "./subchannel-address";
|
||||
import { BaseSubchannelWrapper, ConnectivityStateListener, SubchannelInterface } from "./subchannel-interface";
|
||||
import * as logging from './logging';
|
||||
|
|
|
@ -16,7 +16,6 @@
|
|||
*/
|
||||
|
||||
import { ChannelOptions } from './channel-options';
|
||||
import { Subchannel } from './subchannel';
|
||||
import { SubchannelAddress } from './subchannel-address';
|
||||
import { ConnectivityState } from './connectivity-state';
|
||||
import { Picker } from './picker';
|
||||
|
@ -58,8 +57,8 @@ export interface ChannelControlHelper {
|
|||
* parent while letting others pass through to the parent unmodified. This
|
||||
* allows other code to create these children without needing to know about
|
||||
* all of the methods to be passed through.
|
||||
* @param parent
|
||||
* @param overrides
|
||||
* @param parent
|
||||
* @param overrides
|
||||
*/
|
||||
export function createChildChannelControlHelper(parent: ChannelControlHelper, overrides: Partial<ChannelControlHelper>): ChannelControlHelper {
|
||||
return {
|
||||
|
|
|
@ -21,7 +21,6 @@ import { SubchannelCall } from "./subchannel-call";
|
|||
import { ConnectivityState } from "./connectivity-state";
|
||||
import { LogVerbosity, Status } from "./constants";
|
||||
import { Deadline, getDeadlineTimeoutString } from "./deadline";
|
||||
import { FilterStack, FilterStackFactory } from "./filter-stack";
|
||||
import { InternalChannel } from "./internal-channel";
|
||||
import { Metadata } from "./metadata";
|
||||
import { PickResultType } from "./picker";
|
||||
|
@ -48,7 +47,6 @@ export class LoadBalancingCall implements Call {
|
|||
private readPending = false;
|
||||
private pendingMessage: {context: MessageContext, message: Buffer} | null = null;
|
||||
private pendingHalfClose = false;
|
||||
private pendingChildStatus: StatusObject | null = null;
|
||||
private ended = false;
|
||||
private serviceUrl: string;
|
||||
private metadata: Metadata | null = null;
|
||||
|
@ -104,9 +102,9 @@ export class LoadBalancingCall implements Call {
|
|||
}
|
||||
this.trace('Pick called')
|
||||
const pickResult = this.channel.doPick(this.metadata, this.callConfig.pickInformation);
|
||||
const subchannelString = pickResult.subchannel ?
|
||||
'(' + pickResult.subchannel.getChannelzRef().id + ') ' + pickResult.subchannel.getAddress() :
|
||||
'' + pickResult.subchannel;
|
||||
const subchannelString = pickResult.subchannel ?
|
||||
'(' + pickResult.subchannel.getChannelzRef().id + ') ' + pickResult.subchannel.getAddress() :
|
||||
'' + pickResult.subchannel;
|
||||
this.trace(
|
||||
'Pick result: ' +
|
||||
PickResultType[pickResult.pickResultType] +
|
||||
|
@ -280,4 +278,4 @@ export class LoadBalancingCall implements Call {
|
|||
getCallNumber(): number {
|
||||
return this.callNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ export class MaxMessageSizeFilter extends BaseFilter implements Filter {
|
|||
private maxSendMessageSize: number = DEFAULT_MAX_SEND_MESSAGE_LENGTH;
|
||||
private maxReceiveMessageSize: number = DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH;
|
||||
constructor(
|
||||
private readonly options: ChannelOptions
|
||||
options: ChannelOptions
|
||||
) {
|
||||
super();
|
||||
if ('grpc.max_send_message_length' in options) {
|
||||
|
|
|
@ -229,11 +229,6 @@ export class Metadata {
|
|||
return result;
|
||||
}
|
||||
|
||||
// For compatibility with the other Metadata implementation
|
||||
private _getCoreRepresentation() {
|
||||
return this.internalRepr;
|
||||
}
|
||||
|
||||
/**
|
||||
* This modifies the behavior of JSON.stringify to show an object
|
||||
* representation of the metadata map.
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
*
|
||||
*/
|
||||
|
||||
import { Duplex, Readable, Writable } from 'stream';
|
||||
import { Readable, Writable } from 'stream';
|
||||
import { EmitterAugmentation1 } from './events';
|
||||
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
|
|
@ -42,7 +42,7 @@ class IpResolver implements Resolver {
|
|||
private addresses: SubchannelAddress[] = [];
|
||||
private error: StatusObject | null = null;
|
||||
constructor(
|
||||
private target: GrpcUri,
|
||||
target: GrpcUri,
|
||||
private listener: ResolverListener,
|
||||
channelOptions: ChannelOptions
|
||||
) {
|
||||
|
|
|
@ -18,7 +18,7 @@
|
|||
import { CallCredentials } from "./call-credentials";
|
||||
import { Call, CallStreamOptions, InterceptingListener, MessageContext, StatusObject } from "./call-interface";
|
||||
import { LogVerbosity, Propagate, Status } from "./constants";
|
||||
import { Deadline, deadlineToString, getDeadlineTimeoutString, getRelativeTimeout, minDeadline } from "./deadline";
|
||||
import { Deadline, deadlineToString, getRelativeTimeout, minDeadline } from "./deadline";
|
||||
import { FilterStack, FilterStackFactory } from "./filter-stack";
|
||||
import { InternalChannel } from "./internal-channel";
|
||||
import { Metadata } from "./metadata";
|
||||
|
@ -276,4 +276,4 @@ export class ResolvingCall implements Call {
|
|||
getCallNumber(): number {
|
||||
return this.callNumber;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -36,7 +36,6 @@ import { SubchannelAddress } from './subchannel-address';
|
|||
import { GrpcUri, uriToString } from './uri-parser';
|
||||
import { ChildLoadBalancerHandler } from './load-balancer-child-handler';
|
||||
import { ChannelOptions } from './channel-options';
|
||||
import { PickFirstLoadBalancingConfig } from './load-balancer-pick-first';
|
||||
|
||||
const TRACER_NAME = 'resolving_load_balancer';
|
||||
|
||||
|
@ -44,8 +43,6 @@ function trace(text: string): void {
|
|||
logging.trace(LogVerbosity.DEBUG, TRACER_NAME, text);
|
||||
}
|
||||
|
||||
const DEFAULT_LOAD_BALANCER_NAME = 'pick_first';
|
||||
|
||||
function getDefaultConfigSelector(
|
||||
serviceConfig: ServiceConfig | null
|
||||
): ConfigSelector {
|
||||
|
@ -137,7 +134,7 @@ export class ResolvingLoadBalancer implements LoadBalancer {
|
|||
constructor(
|
||||
private readonly target: GrpcUri,
|
||||
private readonly channelControlHelper: ChannelControlHelper,
|
||||
private readonly channelOptions: ChannelOptions,
|
||||
channelOptions: ChannelOptions,
|
||||
private readonly onSuccessfulResolution: ResolutionCallback,
|
||||
private readonly onFailedResolution: ResolutionFailureCallback
|
||||
) {
|
||||
|
|
|
@ -268,6 +268,9 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
|
|||
implements ServerDuplexStream<RequestType, ResponseType>
|
||||
{
|
||||
cancelled: boolean;
|
||||
/* This field appears to be unsued, but it is actually used in _final, which is assiged from
|
||||
* ServerWritableStreamImpl.prototype._final below. */
|
||||
// @ts-ignore noUnusedLocals
|
||||
private trailingMetadata: Metadata;
|
||||
|
||||
constructor(
|
||||
|
@ -419,7 +422,7 @@ export class Http2ServerCallStream<
|
|||
constructor(
|
||||
private stream: http2.ServerHttp2Stream,
|
||||
private handler: Handler<RequestType, ResponseType>,
|
||||
private options: ChannelOptions
|
||||
options: ChannelOptions
|
||||
) {
|
||||
super();
|
||||
|
||||
|
@ -720,7 +723,7 @@ export class Http2ServerCallStream<
|
|||
[GRPC_MESSAGE_HEADER]: encodeURI(statusObj.details),
|
||||
...statusObj.metadata?.toHttp2Headers(),
|
||||
};
|
||||
|
||||
|
||||
this.stream.sendTrailers(trailersToSend);
|
||||
this.statusSent = true;
|
||||
});
|
||||
|
|
|
@ -141,10 +141,6 @@ interface ChannelzSessionInfo {
|
|||
lastMessageReceivedTimestamp: Date | null;
|
||||
}
|
||||
|
||||
interface ChannelzListenerInfo {
|
||||
ref: SocketRef;
|
||||
}
|
||||
|
||||
export class Server {
|
||||
private http2ServerList: { server: (http2.Http2Server | http2.Http2SecureServer), channelzRef: SocketRef }[] = [];
|
||||
|
||||
|
@ -242,7 +238,7 @@ export class Server {
|
|||
private trace(text: string): void {
|
||||
logging.trace(LogVerbosity.DEBUG, TRACER_NAME, '(' + this.channelzRef.id + ') ' + text);
|
||||
}
|
||||
|
||||
|
||||
|
||||
addProtoService(): never {
|
||||
throw new Error('Not implemented. Use addService() instead');
|
||||
|
@ -743,7 +739,7 @@ export class Server {
|
|||
/**
|
||||
* Get the channelz reference object for this server. The returned value is
|
||||
* garbage if channelz is disabled for this server.
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
getChannelzRef() {
|
||||
return this.channelzRef;
|
||||
|
@ -792,14 +788,14 @@ export class Server {
|
|||
|
||||
return handler
|
||||
}
|
||||
|
||||
|
||||
private _respondWithError<T extends Partial<ServiceError>>(
|
||||
err: T,
|
||||
stream: http2.ServerHttp2Stream,
|
||||
err: T,
|
||||
stream: http2.ServerHttp2Stream,
|
||||
channelzSessionInfo: ChannelzSessionInfo | null = null
|
||||
) {
|
||||
const call = new Http2ServerCallStream(stream, null!, this.options);
|
||||
|
||||
|
||||
if (err.code === undefined) {
|
||||
err.code = Status.INTERNAL;
|
||||
}
|
||||
|
@ -814,7 +810,7 @@ export class Server {
|
|||
|
||||
private _channelzHandler(stream: http2.ServerHttp2Stream, headers: http2.IncomingHttpHeaders) {
|
||||
const channelzSessionInfo = this.sessions.get(stream.session as http2.ServerHttp2Session);
|
||||
|
||||
|
||||
this.callTracker.addCallStarted();
|
||||
channelzSessionInfo?.streamTracker.addCallStarted();
|
||||
|
||||
|
@ -834,9 +830,9 @@ export class Server {
|
|||
}, stream, channelzSessionInfo)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
const call = new Http2ServerCallStream(stream, handler, this.options);
|
||||
|
||||
|
||||
call.once('callEnd', (code: Status) => {
|
||||
if (code === Status.OK) {
|
||||
this.callTracker.addCallSucceeded();
|
||||
|
@ -844,7 +840,7 @@ export class Server {
|
|||
this.callTracker.addCallFailed();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
if (channelzSessionInfo) {
|
||||
call.once('streamEnd', (success: boolean) => {
|
||||
if (success) {
|
||||
|
@ -954,8 +950,8 @@ export class Server {
|
|||
}
|
||||
this.serverAddressString = serverAddressString
|
||||
|
||||
const handler = this.channelzEnabled
|
||||
? this._channelzHandler
|
||||
const handler = this.channelzEnabled
|
||||
? this._channelzHandler
|
||||
: this._streamHandler
|
||||
|
||||
http2Server.on('stream', handler.bind(this))
|
||||
|
|
|
@ -23,19 +23,11 @@ import { Metadata } from './metadata';
|
|||
import { StreamDecoder } from './stream-decoder';
|
||||
import * as logging from './logging';
|
||||
import { LogVerbosity } from './constants';
|
||||
import { ServerSurfaceCall } from './server-call';
|
||||
import { Deadline } from './deadline';
|
||||
import { InterceptingListener, MessageContext, StatusObject, WriteCallback } from './call-interface';
|
||||
import { CallEventTracker, Transport } from './transport';
|
||||
|
||||
const TRACER_NAME = 'subchannel_call';
|
||||
|
||||
const {
|
||||
HTTP2_HEADER_STATUS,
|
||||
HTTP2_HEADER_CONTENT_TYPE,
|
||||
NGHTTP2_CANCEL,
|
||||
} = http2.constants;
|
||||
|
||||
/**
|
||||
* https://nodejs.org/api/errors.html#errors_class_systemerror
|
||||
*/
|
||||
|
|
|
@ -46,10 +46,6 @@ const {
|
|||
HTTP2_HEADER_USER_AGENT,
|
||||
} = http2.constants;
|
||||
|
||||
/* setInterval and setTimeout only accept signed 32 bit integers. JS doesn't
|
||||
* have a constant for the max signed 32 bit integer, so this is a simple way
|
||||
* to calculate it */
|
||||
const KEEPALIVE_MAX_TIME_MS = ~(1 << 31);
|
||||
const KEEPALIVE_TIMEOUT_MS = 20000;
|
||||
|
||||
export interface CallEventTracker {
|
||||
|
@ -108,11 +104,6 @@ class Http2Transport implements Transport {
|
|||
// Channelz info
|
||||
private channelzRef: SocketRef;
|
||||
private readonly channelzEnabled: boolean = true;
|
||||
/**
|
||||
* Name of the remote server, if it is not the same as the subchannel
|
||||
* address, i.e. if connecting through an HTTP CONNECT proxy.
|
||||
*/
|
||||
private remoteName: string | null = null;
|
||||
private streamTracker = new ChannelzCallTracker();
|
||||
private keepalivesSent = 0;
|
||||
private messagesSent = 0;
|
||||
|
@ -123,7 +114,12 @@ class Http2Transport implements Transport {
|
|||
constructor(
|
||||
private session: http2.ClientHttp2Session,
|
||||
subchannelAddress: SubchannelAddress,
|
||||
options: ChannelOptions
|
||||
options: ChannelOptions,
|
||||
/**
|
||||
* Name of the remote server, if it is not the same as the subchannel
|
||||
* address, i.e. if connecting through an HTTP CONNECT proxy.
|
||||
*/
|
||||
private remoteName: string | null
|
||||
) {
|
||||
// Build user-agent string.
|
||||
this.userAgent = [
|
||||
|
@ -133,7 +129,7 @@ class Http2Transport implements Transport {
|
|||
]
|
||||
.filter((e) => e)
|
||||
.join(' '); // remove falsey values first
|
||||
|
||||
|
||||
if ('grpc.keepalive_time_ms' in options) {
|
||||
this.keepaliveTimeMs = options['grpc.keepalive_time_ms']!;
|
||||
}
|
||||
|
@ -271,7 +267,7 @@ class Http2Transport implements Transport {
|
|||
* @param tooManyPings If true, this was triggered by a GOAWAY with data
|
||||
* indicating that the session was closed becaues the client sent too many
|
||||
* pings.
|
||||
* @returns
|
||||
* @returns
|
||||
*/
|
||||
private reportDisconnectToOwner(tooManyPings: boolean) {
|
||||
if (this.disconnectHandled) {
|
||||
|
@ -405,11 +401,11 @@ class Http2Transport implements Transport {
|
|||
this.session.state.remoteWindowSize
|
||||
);
|
||||
this.internalsTrace(
|
||||
'session.closed=' +
|
||||
this.session.closed +
|
||||
' session.destroyed=' +
|
||||
this.session.destroyed +
|
||||
' session.socket.destroyed=' +
|
||||
'session.closed=' +
|
||||
this.session.closed +
|
||||
' session.destroyed=' +
|
||||
this.session.destroyed +
|
||||
' session.socket.destroyed=' +
|
||||
this.session.socket.destroyed);
|
||||
let eventTracker: CallEventTracker;
|
||||
let call: Http2SubchannelCall;
|
||||
|
@ -565,12 +561,12 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
|||
}
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
connectionOptions = {
|
||||
...connectionOptions,
|
||||
...address,
|
||||
};
|
||||
|
||||
|
||||
/* http2.connect uses the options here:
|
||||
* https://github.com/nodejs/node/blob/70c32a6d190e2b5d7b9ff9d5b6a459d14e8b7d59/lib/internal/http2/core.js#L3028-L3036
|
||||
* The spread operator overides earlier values with later ones, so any port
|
||||
|
@ -596,7 +592,7 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
|||
session.unref();
|
||||
session.once('connect', () => {
|
||||
session.removeAllListeners();
|
||||
resolve(new Http2Transport(session, address, options));
|
||||
resolve(new Http2Transport(session, address, options, remoteName));
|
||||
this.session = null;
|
||||
});
|
||||
session.once('close', () => {
|
||||
|
@ -666,4 +662,4 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
|||
this.session?.close();
|
||||
this.session = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,6 @@ describe('Call propagation', () => {
|
|||
describe('Deadlines', () => {
|
||||
it('should work with unary requests', (done) => {
|
||||
done = multiDone(done, 2);
|
||||
let call: grpc.ClientUnaryCall;
|
||||
proxyServer.addService(Client.service, {
|
||||
unary: (parent: grpc.ServerUnaryCall<any, any>, callback: grpc.sendUnaryData<any>) => {
|
||||
client.unary(parent.request, {parent: parent, propagate_flags: grpc.propagate.DEADLINE}, (error: grpc.ServiceError, value: unknown) => {
|
||||
|
@ -178,7 +177,7 @@ describe('Call propagation', () => {
|
|||
});
|
||||
const deadline = new Date();
|
||||
deadline.setMilliseconds(deadline.getMilliseconds() + 100);
|
||||
call = proxyClient.unary({}, {deadline}, (error: grpc.ServiceError, value: unknown) => {
|
||||
proxyClient.unary({}, {deadline}, (error: grpc.ServiceError, value: unknown) => {
|
||||
assert(error);
|
||||
assert.strictEqual(error.code, grpc.status.DEADLINE_EXCEEDED);
|
||||
done();
|
||||
|
@ -186,7 +185,6 @@ describe('Call propagation', () => {
|
|||
});
|
||||
it('Should work with client streaming requests', (done) => {
|
||||
done = multiDone(done, 2);
|
||||
let call: grpc.ClientWritableStream<unknown>;
|
||||
proxyServer.addService(Client.service, {
|
||||
clientStream: (parent: grpc.ServerReadableStream<any, any>, callback: grpc.sendUnaryData<any>) => {
|
||||
client.clientStream({parent: parent, propagate_flags: grpc.propagate.DEADLINE}, (error: grpc.ServiceError, value: unknown) => {
|
||||
|
@ -199,7 +197,7 @@ describe('Call propagation', () => {
|
|||
});
|
||||
const deadline = new Date();
|
||||
deadline.setMilliseconds(deadline.getMilliseconds() + 100);
|
||||
call = proxyClient.clientStream({deadline, propagate_flags: grpc.propagate.DEADLINE}, (error: grpc.ServiceError, value: unknown) => {
|
||||
proxyClient.clientStream({deadline, propagate_flags: grpc.propagate.DEADLINE}, (error: grpc.ServiceError, value: unknown) => {
|
||||
assert(error);
|
||||
assert.strictEqual(error.code, grpc.status.DEADLINE_EXCEEDED);
|
||||
done();
|
||||
|
@ -250,4 +248,4 @@ describe('Call propagation', () => {
|
|||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,14 +19,11 @@ import * as assert from 'assert';
|
|||
import * as fs from 'fs';
|
||||
import * as path from 'path';
|
||||
import { promisify } from 'util';
|
||||
import * as protoLoader from '@grpc/proto-loader';
|
||||
|
||||
import { CallCredentials } from '../src/call-credentials';
|
||||
import { ChannelCredentials } from '../src/channel-credentials';
|
||||
import * as grpc from '../src';
|
||||
import { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
||||
import { TestServiceClient, TestServiceHandlers } from './generated/TestService';
|
||||
import { ProtoGrpcType as TestServiceGrpcType } from './generated/test_service';
|
||||
|
||||
import { assert2, loadProtoFile, mockFunction } from './common';
|
||||
import { sendUnaryData, ServerUnaryCall, ServiceError } from '../src';
|
||||
|
@ -171,7 +168,7 @@ describe('ChannelCredentials usage', () => {
|
|||
callback(null, call.request);
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
server.bindAsync(
|
||||
'localhost:0',
|
||||
serverCreds,
|
||||
|
@ -209,4 +206,4 @@ describe('ChannelCredentials usage', () => {
|
|||
}));
|
||||
assert2.afterMustCallsSatisfied(done);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -21,8 +21,6 @@ import * as grpc from '../src';
|
|||
|
||||
import { ProtoGrpcType } from '../src/generated/channelz'
|
||||
import { ChannelzClient } from '../src/generated/grpc/channelz/v1/Channelz';
|
||||
import { Channel__Output } from '../src/generated/grpc/channelz/v1/Channel';
|
||||
import { Server__Output } from '../src/generated/grpc/channelz/v1/Server';
|
||||
import { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
||||
import { loadProtoFile } from './common';
|
||||
|
||||
|
@ -318,4 +316,4 @@ describe('Disabling channelz', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -19,14 +19,10 @@ import * as assert from 'assert';
|
|||
|
||||
import * as grpc from '../src';
|
||||
import { experimental } from '../src';
|
||||
import { ServerCredentials } from '../src';
|
||||
import { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
||||
import { loadProtoFile } from './common';
|
||||
import ServiceConfig = experimental.ServiceConfig;
|
||||
|
||||
const clientInsecureCreds = grpc.credentials.createInsecure();
|
||||
const serverInsecureCreds = ServerCredentials.createInsecure();
|
||||
|
||||
const TIMEOUT_SERVICE_CONFIG: ServiceConfig = {
|
||||
loadBalancingConfig: [],
|
||||
methodConfig: [{
|
||||
|
@ -44,7 +40,7 @@ describe('Client with configured timeout', () => {
|
|||
let server: grpc.Server;
|
||||
let Client: ServiceClientConstructor;
|
||||
let client: ServiceClient;
|
||||
|
||||
|
||||
before(done => {
|
||||
Client = loadProtoFile(__dirname + '/fixtures/test_service.proto').TestService as ServiceClientConstructor;
|
||||
server = new grpc.Server();
|
||||
|
@ -87,4 +83,4 @@ describe('Client with configured timeout', () => {
|
|||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
@ -20,7 +20,6 @@ import * as path from 'path';
|
|||
import * as grpc from '../src';
|
||||
import { loadProtoFile } from './common';
|
||||
import { OutlierDetectionLoadBalancingConfig } from '../src/load-balancer-outlier-detection'
|
||||
import { ServiceClient } from '../src/make-client';
|
||||
|
||||
function multiDone(done: Mocha.Done, target: number) {
|
||||
let count = 0;
|
||||
|
|
|
@ -686,7 +686,7 @@ describe('Compressed requests', () => {
|
|||
},
|
||||
|
||||
ServerStream(call) {
|
||||
const { metadata, request } = call;
|
||||
const { request } = call;
|
||||
|
||||
for (let i = 0; i < 5; i++) {
|
||||
call.write({ count: request.message.length });
|
||||
|
@ -908,7 +908,7 @@ describe('Compressed requests', () => {
|
|||
done();
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
/* As of Node 16, Writable and Duplex streams validate the encoding
|
||||
* argument to write, and the flags values we are passing there are not
|
||||
* valid. We don't currently have an alternative way to pass that flag
|
||||
|
|
|
@ -7,7 +7,8 @@
|
|||
"module": "commonjs",
|
||||
"resolveJsonModule": true,
|
||||
"incremental": true,
|
||||
"types": ["mocha"]
|
||||
"types": ["mocha"],
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
|
|
Loading…
Reference in New Issue