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
|
cert: PeerCertificate
|
||||||
) => Error | undefined;
|
) => 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
|
* Additional peer verification options that can be set when creating
|
||||||
* SSL credentials.
|
* SSL credentials.
|
||||||
|
|
|
@ -32,7 +32,6 @@ import {
|
||||||
import { Status } from './constants';
|
import { Status } from './constants';
|
||||||
import { Channel } from './channel';
|
import { Channel } from './channel';
|
||||||
import { CallOptions } from './client';
|
import { CallOptions } from './client';
|
||||||
import { CallCredentials } from './call-credentials';
|
|
||||||
import { ClientMethodDefinition } from './make-client';
|
import { ClientMethodDefinition } from './make-client';
|
||||||
import { getErrorMessage } from './error';
|
import { getErrorMessage } from './error';
|
||||||
|
|
||||||
|
|
|
@ -282,7 +282,7 @@ export class CompressionFilter extends BaseFilter implements Filter {
|
||||||
export class CompressionFilterFactory
|
export class CompressionFilterFactory
|
||||||
implements FilterFactory<CompressionFilter> {
|
implements FilterFactory<CompressionFilter> {
|
||||||
private sharedFilterConfig: SharedCompressionFilterConfig = {};
|
private sharedFilterConfig: SharedCompressionFilterConfig = {};
|
||||||
constructor(private readonly channel: Channel, private readonly options: ChannelOptions) {}
|
constructor(channel: Channel, private readonly options: ChannelOptions) {}
|
||||||
createFilter(): CompressionFilter {
|
createFilter(): CompressionFilter {
|
||||||
return new CompressionFilter(this.options, this.sharedFilterConfig);
|
return new CompressionFilter(this.options, this.sharedFilterConfig);
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,9 +43,7 @@ import {
|
||||||
loadPackageDefinition,
|
loadPackageDefinition,
|
||||||
makeClientConstructor,
|
makeClientConstructor,
|
||||||
MethodDefinition,
|
MethodDefinition,
|
||||||
ProtobufTypeDefinition,
|
|
||||||
Serialize,
|
Serialize,
|
||||||
ServiceClientConstructor,
|
|
||||||
ServiceDefinition,
|
ServiceDefinition,
|
||||||
} from './make-client';
|
} from './make-client';
|
||||||
import { Metadata, MetadataOptions, MetadataValue } from './metadata';
|
import { Metadata, MetadataOptions, MetadataValue } from './metadata';
|
||||||
|
|
|
@ -20,7 +20,7 @@ import { ChannelOptions } from './channel-options';
|
||||||
import { ResolvingLoadBalancer } from './resolving-load-balancer';
|
import { ResolvingLoadBalancer } from './resolving-load-balancer';
|
||||||
import { SubchannelPool, getSubchannelPool } from './subchannel-pool';
|
import { SubchannelPool, getSubchannelPool } from './subchannel-pool';
|
||||||
import { ChannelControlHelper } from './load-balancer';
|
import { ChannelControlHelper } from './load-balancer';
|
||||||
import { UnavailablePicker, Picker, PickResultType } from './picker';
|
import { UnavailablePicker, Picker } from './picker';
|
||||||
import { Metadata } from './metadata';
|
import { Metadata } from './metadata';
|
||||||
import { Status, LogVerbosity, Propagate } from './constants';
|
import { Status, LogVerbosity, Propagate } from './constants';
|
||||||
import { FilterStackFactory } from './filter-stack';
|
import { FilterStackFactory } from './filter-stack';
|
||||||
|
@ -31,22 +31,19 @@ import {
|
||||||
getDefaultAuthority,
|
getDefaultAuthority,
|
||||||
mapUriDefaultScheme,
|
mapUriDefaultScheme,
|
||||||
} from './resolver';
|
} from './resolver';
|
||||||
import { trace, log } from './logging';
|
import { trace } from './logging';
|
||||||
import { SubchannelAddress } from './subchannel-address';
|
import { SubchannelAddress } from './subchannel-address';
|
||||||
import { MaxMessageSizeFilterFactory } from './max-message-size-filter';
|
import { MaxMessageSizeFilterFactory } from './max-message-size-filter';
|
||||||
import { mapProxyName } from './http_proxy';
|
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 { ServerSurfaceCall } from './server-call';
|
||||||
import { Filter } from './filter';
|
|
||||||
|
|
||||||
import { ConnectivityState } from './connectivity-state';
|
import { ConnectivityState } from './connectivity-state';
|
||||||
import { ChannelInfo, ChannelRef, ChannelzCallTracker, ChannelzChildrenTracker, ChannelzTrace, registerChannelzChannel, SubchannelRef, unregisterChannelzRef } from './channelz';
|
import { ChannelInfo, ChannelRef, ChannelzCallTracker, ChannelzChildrenTracker, ChannelzTrace, registerChannelzChannel, SubchannelRef, unregisterChannelzRef } from './channelz';
|
||||||
import { Subchannel } from './subchannel';
|
|
||||||
import { LoadBalancingCall } from './load-balancing-call';
|
import { LoadBalancingCall } from './load-balancing-call';
|
||||||
import { CallCredentials } from './call-credentials';
|
import { CallCredentials } from './call-credentials';
|
||||||
import { Call, CallStreamOptions, InterceptingListener, MessageContext, StatusObject } from './call-interface';
|
import { Call, CallStreamOptions, StatusObject } from './call-interface';
|
||||||
import { SubchannelCall } from './subchannel-call';
|
import { Deadline, deadlineToString } from './deadline';
|
||||||
import { Deadline, deadlineToString, getDeadlineTimeoutString } from './deadline';
|
|
||||||
import { ResolvingCall } from './resolving-call';
|
import { ResolvingCall } from './resolving-call';
|
||||||
import { getNextCallNumber } from './call-number';
|
import { getNextCallNumber } from './call-number';
|
||||||
import { restrictControlPlaneStatusCode } from './control-plane-status';
|
import { restrictControlPlaneStatusCode } from './control-plane-status';
|
||||||
|
|
|
@ -20,11 +20,9 @@ import { ConnectivityState } from "./connectivity-state";
|
||||||
import { LogVerbosity, Status } from "./constants";
|
import { LogVerbosity, Status } from "./constants";
|
||||||
import { durationToMs, isDuration, msToDuration } from "./duration";
|
import { durationToMs, isDuration, msToDuration } from "./duration";
|
||||||
import { ChannelControlHelper, createChildChannelControlHelper, registerLoadBalancerType } from "./experimental";
|
import { ChannelControlHelper, createChildChannelControlHelper, registerLoadBalancerType } from "./experimental";
|
||||||
import { BaseFilter, Filter, FilterFactory } from "./filter";
|
|
||||||
import { getFirstUsableConfig, LoadBalancer, LoadBalancingConfig, validateLoadBalancingConfig } from "./load-balancer";
|
import { getFirstUsableConfig, LoadBalancer, LoadBalancingConfig, validateLoadBalancingConfig } from "./load-balancer";
|
||||||
import { ChildLoadBalancerHandler } from "./load-balancer-child-handler";
|
import { ChildLoadBalancerHandler } from "./load-balancer-child-handler";
|
||||||
import { PickArgs, Picker, PickResult, PickResultType, QueuePicker, UnavailablePicker } from "./picker";
|
import { PickArgs, Picker, PickResult, PickResultType } from "./picker";
|
||||||
import { Subchannel } from "./subchannel";
|
|
||||||
import { SubchannelAddress, subchannelAddressToString } from "./subchannel-address";
|
import { SubchannelAddress, subchannelAddressToString } from "./subchannel-address";
|
||||||
import { BaseSubchannelWrapper, ConnectivityStateListener, SubchannelInterface } from "./subchannel-interface";
|
import { BaseSubchannelWrapper, ConnectivityStateListener, SubchannelInterface } from "./subchannel-interface";
|
||||||
import * as logging from './logging';
|
import * as logging from './logging';
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { ChannelOptions } from './channel-options';
|
import { ChannelOptions } from './channel-options';
|
||||||
import { Subchannel } from './subchannel';
|
|
||||||
import { SubchannelAddress } from './subchannel-address';
|
import { SubchannelAddress } from './subchannel-address';
|
||||||
import { ConnectivityState } from './connectivity-state';
|
import { ConnectivityState } from './connectivity-state';
|
||||||
import { Picker } from './picker';
|
import { Picker } from './picker';
|
||||||
|
|
|
@ -21,7 +21,6 @@ import { SubchannelCall } from "./subchannel-call";
|
||||||
import { ConnectivityState } from "./connectivity-state";
|
import { ConnectivityState } from "./connectivity-state";
|
||||||
import { LogVerbosity, Status } from "./constants";
|
import { LogVerbosity, Status } from "./constants";
|
||||||
import { Deadline, getDeadlineTimeoutString } from "./deadline";
|
import { Deadline, getDeadlineTimeoutString } from "./deadline";
|
||||||
import { FilterStack, FilterStackFactory } from "./filter-stack";
|
|
||||||
import { InternalChannel } from "./internal-channel";
|
import { InternalChannel } from "./internal-channel";
|
||||||
import { Metadata } from "./metadata";
|
import { Metadata } from "./metadata";
|
||||||
import { PickResultType } from "./picker";
|
import { PickResultType } from "./picker";
|
||||||
|
@ -48,7 +47,6 @@ export class LoadBalancingCall implements Call {
|
||||||
private readPending = false;
|
private readPending = false;
|
||||||
private pendingMessage: {context: MessageContext, message: Buffer} | null = null;
|
private pendingMessage: {context: MessageContext, message: Buffer} | null = null;
|
||||||
private pendingHalfClose = false;
|
private pendingHalfClose = false;
|
||||||
private pendingChildStatus: StatusObject | null = null;
|
|
||||||
private ended = false;
|
private ended = false;
|
||||||
private serviceUrl: string;
|
private serviceUrl: string;
|
||||||
private metadata: Metadata | null = null;
|
private metadata: Metadata | null = null;
|
||||||
|
|
|
@ -29,7 +29,7 @@ export class MaxMessageSizeFilter extends BaseFilter implements Filter {
|
||||||
private maxSendMessageSize: number = DEFAULT_MAX_SEND_MESSAGE_LENGTH;
|
private maxSendMessageSize: number = DEFAULT_MAX_SEND_MESSAGE_LENGTH;
|
||||||
private maxReceiveMessageSize: number = DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH;
|
private maxReceiveMessageSize: number = DEFAULT_MAX_RECEIVE_MESSAGE_LENGTH;
|
||||||
constructor(
|
constructor(
|
||||||
private readonly options: ChannelOptions
|
options: ChannelOptions
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
if ('grpc.max_send_message_length' in options) {
|
if ('grpc.max_send_message_length' in options) {
|
||||||
|
|
|
@ -229,11 +229,6 @@ export class Metadata {
|
||||||
return result;
|
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
|
* This modifies the behavior of JSON.stringify to show an object
|
||||||
* representation of the metadata map.
|
* representation of the metadata map.
|
||||||
|
|
|
@ -15,7 +15,7 @@
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { Duplex, Readable, Writable } from 'stream';
|
import { Readable, Writable } from 'stream';
|
||||||
import { EmitterAugmentation1 } from './events';
|
import { EmitterAugmentation1 } from './events';
|
||||||
|
|
||||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||||
|
|
|
@ -42,7 +42,7 @@ class IpResolver implements Resolver {
|
||||||
private addresses: SubchannelAddress[] = [];
|
private addresses: SubchannelAddress[] = [];
|
||||||
private error: StatusObject | null = null;
|
private error: StatusObject | null = null;
|
||||||
constructor(
|
constructor(
|
||||||
private target: GrpcUri,
|
target: GrpcUri,
|
||||||
private listener: ResolverListener,
|
private listener: ResolverListener,
|
||||||
channelOptions: ChannelOptions
|
channelOptions: ChannelOptions
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
import { CallCredentials } from "./call-credentials";
|
import { CallCredentials } from "./call-credentials";
|
||||||
import { Call, CallStreamOptions, InterceptingListener, MessageContext, StatusObject } from "./call-interface";
|
import { Call, CallStreamOptions, InterceptingListener, MessageContext, StatusObject } from "./call-interface";
|
||||||
import { LogVerbosity, Propagate, Status } from "./constants";
|
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 { FilterStack, FilterStackFactory } from "./filter-stack";
|
||||||
import { InternalChannel } from "./internal-channel";
|
import { InternalChannel } from "./internal-channel";
|
||||||
import { Metadata } from "./metadata";
|
import { Metadata } from "./metadata";
|
||||||
|
|
|
@ -36,7 +36,6 @@ import { SubchannelAddress } from './subchannel-address';
|
||||||
import { GrpcUri, uriToString } from './uri-parser';
|
import { GrpcUri, uriToString } from './uri-parser';
|
||||||
import { ChildLoadBalancerHandler } from './load-balancer-child-handler';
|
import { ChildLoadBalancerHandler } from './load-balancer-child-handler';
|
||||||
import { ChannelOptions } from './channel-options';
|
import { ChannelOptions } from './channel-options';
|
||||||
import { PickFirstLoadBalancingConfig } from './load-balancer-pick-first';
|
|
||||||
|
|
||||||
const TRACER_NAME = 'resolving_load_balancer';
|
const TRACER_NAME = 'resolving_load_balancer';
|
||||||
|
|
||||||
|
@ -44,8 +43,6 @@ function trace(text: string): void {
|
||||||
logging.trace(LogVerbosity.DEBUG, TRACER_NAME, text);
|
logging.trace(LogVerbosity.DEBUG, TRACER_NAME, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
const DEFAULT_LOAD_BALANCER_NAME = 'pick_first';
|
|
||||||
|
|
||||||
function getDefaultConfigSelector(
|
function getDefaultConfigSelector(
|
||||||
serviceConfig: ServiceConfig | null
|
serviceConfig: ServiceConfig | null
|
||||||
): ConfigSelector {
|
): ConfigSelector {
|
||||||
|
@ -137,7 +134,7 @@ export class ResolvingLoadBalancer implements LoadBalancer {
|
||||||
constructor(
|
constructor(
|
||||||
private readonly target: GrpcUri,
|
private readonly target: GrpcUri,
|
||||||
private readonly channelControlHelper: ChannelControlHelper,
|
private readonly channelControlHelper: ChannelControlHelper,
|
||||||
private readonly channelOptions: ChannelOptions,
|
channelOptions: ChannelOptions,
|
||||||
private readonly onSuccessfulResolution: ResolutionCallback,
|
private readonly onSuccessfulResolution: ResolutionCallback,
|
||||||
private readonly onFailedResolution: ResolutionFailureCallback
|
private readonly onFailedResolution: ResolutionFailureCallback
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -268,6 +268,9 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
|
||||||
implements ServerDuplexStream<RequestType, ResponseType>
|
implements ServerDuplexStream<RequestType, ResponseType>
|
||||||
{
|
{
|
||||||
cancelled: boolean;
|
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;
|
private trailingMetadata: Metadata;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
|
@ -419,7 +422,7 @@ export class Http2ServerCallStream<
|
||||||
constructor(
|
constructor(
|
||||||
private stream: http2.ServerHttp2Stream,
|
private stream: http2.ServerHttp2Stream,
|
||||||
private handler: Handler<RequestType, ResponseType>,
|
private handler: Handler<RequestType, ResponseType>,
|
||||||
private options: ChannelOptions
|
options: ChannelOptions
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
|
|
||||||
|
|
|
@ -141,10 +141,6 @@ interface ChannelzSessionInfo {
|
||||||
lastMessageReceivedTimestamp: Date | null;
|
lastMessageReceivedTimestamp: Date | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ChannelzListenerInfo {
|
|
||||||
ref: SocketRef;
|
|
||||||
}
|
|
||||||
|
|
||||||
export class Server {
|
export class Server {
|
||||||
private http2ServerList: { server: (http2.Http2Server | http2.Http2SecureServer), channelzRef: SocketRef }[] = [];
|
private http2ServerList: { server: (http2.Http2Server | http2.Http2SecureServer), channelzRef: SocketRef }[] = [];
|
||||||
|
|
||||||
|
|
|
@ -23,19 +23,11 @@ import { Metadata } from './metadata';
|
||||||
import { StreamDecoder } from './stream-decoder';
|
import { StreamDecoder } from './stream-decoder';
|
||||||
import * as logging from './logging';
|
import * as logging from './logging';
|
||||||
import { LogVerbosity } from './constants';
|
import { LogVerbosity } from './constants';
|
||||||
import { ServerSurfaceCall } from './server-call';
|
|
||||||
import { Deadline } from './deadline';
|
|
||||||
import { InterceptingListener, MessageContext, StatusObject, WriteCallback } from './call-interface';
|
import { InterceptingListener, MessageContext, StatusObject, WriteCallback } from './call-interface';
|
||||||
import { CallEventTracker, Transport } from './transport';
|
import { CallEventTracker, Transport } from './transport';
|
||||||
|
|
||||||
const TRACER_NAME = 'subchannel_call';
|
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
|
* https://nodejs.org/api/errors.html#errors_class_systemerror
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -46,10 +46,6 @@ const {
|
||||||
HTTP2_HEADER_USER_AGENT,
|
HTTP2_HEADER_USER_AGENT,
|
||||||
} = http2.constants;
|
} = 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;
|
const KEEPALIVE_TIMEOUT_MS = 20000;
|
||||||
|
|
||||||
export interface CallEventTracker {
|
export interface CallEventTracker {
|
||||||
|
@ -108,11 +104,6 @@ class Http2Transport implements Transport {
|
||||||
// Channelz info
|
// Channelz info
|
||||||
private channelzRef: SocketRef;
|
private channelzRef: SocketRef;
|
||||||
private readonly channelzEnabled: boolean = true;
|
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 streamTracker = new ChannelzCallTracker();
|
||||||
private keepalivesSent = 0;
|
private keepalivesSent = 0;
|
||||||
private messagesSent = 0;
|
private messagesSent = 0;
|
||||||
|
@ -123,7 +114,12 @@ class Http2Transport implements Transport {
|
||||||
constructor(
|
constructor(
|
||||||
private session: http2.ClientHttp2Session,
|
private session: http2.ClientHttp2Session,
|
||||||
subchannelAddress: SubchannelAddress,
|
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.
|
// Build user-agent string.
|
||||||
this.userAgent = [
|
this.userAgent = [
|
||||||
|
@ -596,7 +592,7 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
||||||
session.unref();
|
session.unref();
|
||||||
session.once('connect', () => {
|
session.once('connect', () => {
|
||||||
session.removeAllListeners();
|
session.removeAllListeners();
|
||||||
resolve(new Http2Transport(session, address, options));
|
resolve(new Http2Transport(session, address, options, remoteName));
|
||||||
this.session = null;
|
this.session = null;
|
||||||
});
|
});
|
||||||
session.once('close', () => {
|
session.once('close', () => {
|
||||||
|
|
|
@ -165,7 +165,6 @@ describe('Call propagation', () => {
|
||||||
describe('Deadlines', () => {
|
describe('Deadlines', () => {
|
||||||
it('should work with unary requests', (done) => {
|
it('should work with unary requests', (done) => {
|
||||||
done = multiDone(done, 2);
|
done = multiDone(done, 2);
|
||||||
let call: grpc.ClientUnaryCall;
|
|
||||||
proxyServer.addService(Client.service, {
|
proxyServer.addService(Client.service, {
|
||||||
unary: (parent: grpc.ServerUnaryCall<any, any>, callback: grpc.sendUnaryData<any>) => {
|
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) => {
|
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();
|
const deadline = new Date();
|
||||||
deadline.setMilliseconds(deadline.getMilliseconds() + 100);
|
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(error);
|
||||||
assert.strictEqual(error.code, grpc.status.DEADLINE_EXCEEDED);
|
assert.strictEqual(error.code, grpc.status.DEADLINE_EXCEEDED);
|
||||||
done();
|
done();
|
||||||
|
@ -186,7 +185,6 @@ describe('Call propagation', () => {
|
||||||
});
|
});
|
||||||
it('Should work with client streaming requests', (done) => {
|
it('Should work with client streaming requests', (done) => {
|
||||||
done = multiDone(done, 2);
|
done = multiDone(done, 2);
|
||||||
let call: grpc.ClientWritableStream<unknown>;
|
|
||||||
proxyServer.addService(Client.service, {
|
proxyServer.addService(Client.service, {
|
||||||
clientStream: (parent: grpc.ServerReadableStream<any, any>, callback: grpc.sendUnaryData<any>) => {
|
clientStream: (parent: grpc.ServerReadableStream<any, any>, callback: grpc.sendUnaryData<any>) => {
|
||||||
client.clientStream({parent: parent, propagate_flags: grpc.propagate.DEADLINE}, (error: grpc.ServiceError, value: unknown) => {
|
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();
|
const deadline = new Date();
|
||||||
deadline.setMilliseconds(deadline.getMilliseconds() + 100);
|
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(error);
|
||||||
assert.strictEqual(error.code, grpc.status.DEADLINE_EXCEEDED);
|
assert.strictEqual(error.code, grpc.status.DEADLINE_EXCEEDED);
|
||||||
done();
|
done();
|
||||||
|
|
|
@ -19,14 +19,11 @@ import * as assert from 'assert';
|
||||||
import * as fs from 'fs';
|
import * as fs from 'fs';
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import { promisify } from 'util';
|
import { promisify } from 'util';
|
||||||
import * as protoLoader from '@grpc/proto-loader';
|
|
||||||
|
|
||||||
import { CallCredentials } from '../src/call-credentials';
|
import { CallCredentials } from '../src/call-credentials';
|
||||||
import { ChannelCredentials } from '../src/channel-credentials';
|
import { ChannelCredentials } from '../src/channel-credentials';
|
||||||
import * as grpc from '../src';
|
import * as grpc from '../src';
|
||||||
import { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
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 { assert2, loadProtoFile, mockFunction } from './common';
|
||||||
import { sendUnaryData, ServerUnaryCall, ServiceError } from '../src';
|
import { sendUnaryData, ServerUnaryCall, ServiceError } from '../src';
|
||||||
|
|
|
@ -21,8 +21,6 @@ import * as grpc from '../src';
|
||||||
|
|
||||||
import { ProtoGrpcType } from '../src/generated/channelz'
|
import { ProtoGrpcType } from '../src/generated/channelz'
|
||||||
import { ChannelzClient } from '../src/generated/grpc/channelz/v1/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 { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
||||||
import { loadProtoFile } from './common';
|
import { loadProtoFile } from './common';
|
||||||
|
|
||||||
|
|
|
@ -19,14 +19,10 @@ import * as assert from 'assert';
|
||||||
|
|
||||||
import * as grpc from '../src';
|
import * as grpc from '../src';
|
||||||
import { experimental } from '../src';
|
import { experimental } from '../src';
|
||||||
import { ServerCredentials } from '../src';
|
|
||||||
import { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
import { ServiceClient, ServiceClientConstructor } from '../src/make-client';
|
||||||
import { loadProtoFile } from './common';
|
import { loadProtoFile } from './common';
|
||||||
import ServiceConfig = experimental.ServiceConfig;
|
import ServiceConfig = experimental.ServiceConfig;
|
||||||
|
|
||||||
const clientInsecureCreds = grpc.credentials.createInsecure();
|
|
||||||
const serverInsecureCreds = ServerCredentials.createInsecure();
|
|
||||||
|
|
||||||
const TIMEOUT_SERVICE_CONFIG: ServiceConfig = {
|
const TIMEOUT_SERVICE_CONFIG: ServiceConfig = {
|
||||||
loadBalancingConfig: [],
|
loadBalancingConfig: [],
|
||||||
methodConfig: [{
|
methodConfig: [{
|
||||||
|
|
|
@ -20,7 +20,6 @@ import * as path from 'path';
|
||||||
import * as grpc from '../src';
|
import * as grpc from '../src';
|
||||||
import { loadProtoFile } from './common';
|
import { loadProtoFile } from './common';
|
||||||
import { OutlierDetectionLoadBalancingConfig } from '../src/load-balancer-outlier-detection'
|
import { OutlierDetectionLoadBalancingConfig } from '../src/load-balancer-outlier-detection'
|
||||||
import { ServiceClient } from '../src/make-client';
|
|
||||||
|
|
||||||
function multiDone(done: Mocha.Done, target: number) {
|
function multiDone(done: Mocha.Done, target: number) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
|
|
@ -686,7 +686,7 @@ describe('Compressed requests', () => {
|
||||||
},
|
},
|
||||||
|
|
||||||
ServerStream(call) {
|
ServerStream(call) {
|
||||||
const { metadata, request } = call;
|
const { request } = call;
|
||||||
|
|
||||||
for (let i = 0; i < 5; i++) {
|
for (let i = 0; i < 5; i++) {
|
||||||
call.write({ count: request.message.length });
|
call.write({ count: request.message.length });
|
||||||
|
|
|
@ -7,7 +7,8 @@
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"incremental": true,
|
"incremental": true,
|
||||||
"types": ["mocha"]
|
"types": ["mocha"],
|
||||||
|
"noUnusedLocals": true
|
||||||
},
|
},
|
||||||
"include": [
|
"include": [
|
||||||
"src/**/*.ts",
|
"src/**/*.ts",
|
||||||
|
|
Loading…
Reference in New Issue