mirror of https://github.com/grpc/grpc-node.git
Merge pull request #2505 from murgatroid99/v1.18.x_upmerge
Merge v1.18.x into master (with formatting fixes)
This commit is contained in:
commit
6b036f3350
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "@grpc/grpc-js",
|
||||
"version": "1.8.14",
|
||||
"version": "1.8.18",
|
||||
"description": "gRPC Library for Node - pure JS implementation",
|
||||
"homepage": "https://grpc.io/",
|
||||
"repository": "https://github.com/grpc/grpc-node/tree/master/packages/grpc-js",
|
||||
|
|
|
@ -43,14 +43,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.
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -322,7 +322,7 @@ export class Client {
|
|||
emitter.call = call;
|
||||
let responseMessage: ResponseType | null = null;
|
||||
let receivedStatus = false;
|
||||
const callerStackError = new Error();
|
||||
let callerStackError: Error | null = new Error();
|
||||
call.start(callProperties.metadata, {
|
||||
onReceiveMetadata: metadata => {
|
||||
emitter.emit('metadata', metadata);
|
||||
|
@ -341,7 +341,7 @@ export class Client {
|
|||
receivedStatus = true;
|
||||
if (status.code === Status.OK) {
|
||||
if (responseMessage === null) {
|
||||
const callerStack = getErrorStackString(callerStackError);
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
callProperties.callback!(
|
||||
callErrorFromStatus(
|
||||
{
|
||||
|
@ -356,9 +356,12 @@ export class Client {
|
|||
callProperties.callback!(null, responseMessage);
|
||||
}
|
||||
} else {
|
||||
const callerStack = getErrorStackString(callerStackError);
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
callProperties.callback!(callErrorFromStatus(status, callerStack));
|
||||
}
|
||||
/* Avoid retaining the callerStackError object in the call context of
|
||||
* the status event handler. */
|
||||
callerStackError = null;
|
||||
emitter.emit('status', status);
|
||||
},
|
||||
});
|
||||
|
@ -452,7 +455,7 @@ export class Client {
|
|||
emitter.call = call;
|
||||
let responseMessage: ResponseType | null = null;
|
||||
let receivedStatus = false;
|
||||
const callerStackError = new Error();
|
||||
let callerStackError: Error | null = new Error();
|
||||
call.start(callProperties.metadata, {
|
||||
onReceiveMetadata: metadata => {
|
||||
emitter.emit('metadata', metadata);
|
||||
|
@ -471,7 +474,7 @@ export class Client {
|
|||
receivedStatus = true;
|
||||
if (status.code === Status.OK) {
|
||||
if (responseMessage === null) {
|
||||
const callerStack = getErrorStackString(callerStackError);
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
callProperties.callback!(
|
||||
callErrorFromStatus(
|
||||
{
|
||||
|
@ -486,9 +489,12 @@ export class Client {
|
|||
callProperties.callback!(null, responseMessage);
|
||||
}
|
||||
} else {
|
||||
const callerStack = getErrorStackString(callerStackError);
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
callProperties.callback!(callErrorFromStatus(status, callerStack));
|
||||
}
|
||||
/* Avoid retaining the callerStackError object in the call context of
|
||||
* the status event handler. */
|
||||
callerStackError = null;
|
||||
emitter.emit('status', status);
|
||||
},
|
||||
});
|
||||
|
@ -585,7 +591,7 @@ export class Client {
|
|||
* call after that. */
|
||||
stream.call = call;
|
||||
let receivedStatus = false;
|
||||
const callerStackError = new Error();
|
||||
let callerStackError: Error | null = new Error();
|
||||
call.start(callProperties.metadata, {
|
||||
onReceiveMetadata(metadata: Metadata) {
|
||||
stream.emit('metadata', metadata);
|
||||
|
@ -601,9 +607,12 @@ export class Client {
|
|||
receivedStatus = true;
|
||||
stream.push(null);
|
||||
if (status.code !== Status.OK) {
|
||||
const callerStack = getErrorStackString(callerStackError);
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
stream.emit('error', callErrorFromStatus(status, callerStack));
|
||||
}
|
||||
/* Avoid retaining the callerStackError object in the call context of
|
||||
* the status event handler. */
|
||||
callerStackError = null;
|
||||
stream.emit('status', status);
|
||||
},
|
||||
});
|
||||
|
@ -677,7 +686,7 @@ export class Client {
|
|||
* call after that. */
|
||||
stream.call = call;
|
||||
let receivedStatus = false;
|
||||
const callerStackError = new Error();
|
||||
let callerStackError: Error | null = new Error();
|
||||
call.start(callProperties.metadata, {
|
||||
onReceiveMetadata(metadata: Metadata) {
|
||||
stream.emit('metadata', metadata);
|
||||
|
@ -692,9 +701,12 @@ export class Client {
|
|||
receivedStatus = true;
|
||||
stream.push(null);
|
||||
if (status.code !== Status.OK) {
|
||||
const callerStack = getErrorStackString(callerStackError);
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
stream.emit('error', callErrorFromStatus(status, callerStack));
|
||||
}
|
||||
/* Avoid retaining the callerStackError object in the call context of
|
||||
* the status event handler. */
|
||||
callerStackError = null;
|
||||
stream.emit('status', status);
|
||||
},
|
||||
});
|
||||
|
|
|
@ -308,10 +308,7 @@ 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);
|
||||
}
|
||||
|
|
|
@ -3,21 +3,37 @@
|
|||
|
||||
// Original file: proto/channelz.proto
|
||||
|
||||
export enum _grpc_channelz_v1_ChannelConnectivityState_State {
|
||||
UNKNOWN = 0,
|
||||
IDLE = 1,
|
||||
CONNECTING = 2,
|
||||
READY = 3,
|
||||
TRANSIENT_FAILURE = 4,
|
||||
SHUTDOWN = 5,
|
||||
}
|
||||
export const _grpc_channelz_v1_ChannelConnectivityState_State = {
|
||||
UNKNOWN: 'UNKNOWN',
|
||||
IDLE: 'IDLE',
|
||||
CONNECTING: 'CONNECTING',
|
||||
READY: 'READY',
|
||||
TRANSIENT_FAILURE: 'TRANSIENT_FAILURE',
|
||||
SHUTDOWN: 'SHUTDOWN',
|
||||
} as const;
|
||||
|
||||
export type _grpc_channelz_v1_ChannelConnectivityState_State =
|
||||
| 'UNKNOWN'
|
||||
| 0
|
||||
| 'IDLE'
|
||||
| 1
|
||||
| 'CONNECTING'
|
||||
| 2
|
||||
| 'READY'
|
||||
| 3
|
||||
| 'TRANSIENT_FAILURE'
|
||||
| 4
|
||||
| 'SHUTDOWN'
|
||||
| 5
|
||||
|
||||
export type _grpc_channelz_v1_ChannelConnectivityState_State__Output = typeof _grpc_channelz_v1_ChannelConnectivityState_State[keyof typeof _grpc_channelz_v1_ChannelConnectivityState_State]
|
||||
|
||||
/**
|
||||
* These come from the specified states in this document:
|
||||
* https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md
|
||||
*/
|
||||
export interface ChannelConnectivityState {
|
||||
'state'?: (_grpc_channelz_v1_ChannelConnectivityState_State | keyof typeof _grpc_channelz_v1_ChannelConnectivityState_State);
|
||||
'state'?: (_grpc_channelz_v1_ChannelConnectivityState_State);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -25,5 +41,5 @@ export interface ChannelConnectivityState {
|
|||
* https://github.com/grpc/grpc/blob/master/doc/connectivity-semantics-and-api.md
|
||||
*/
|
||||
export interface ChannelConnectivityState__Output {
|
||||
'state': (keyof typeof _grpc_channelz_v1_ChannelConnectivityState_State);
|
||||
'state': (_grpc_channelz_v1_ChannelConnectivityState_State__Output);
|
||||
}
|
||||
|
|
|
@ -9,12 +9,30 @@ import type { SubchannelRef as _grpc_channelz_v1_SubchannelRef, SubchannelRef__O
|
|||
/**
|
||||
* The supported severity levels of trace events.
|
||||
*/
|
||||
export enum _grpc_channelz_v1_ChannelTraceEvent_Severity {
|
||||
CT_UNKNOWN = 0,
|
||||
CT_INFO = 1,
|
||||
CT_WARNING = 2,
|
||||
CT_ERROR = 3,
|
||||
}
|
||||
export const _grpc_channelz_v1_ChannelTraceEvent_Severity = {
|
||||
CT_UNKNOWN: 'CT_UNKNOWN',
|
||||
CT_INFO: 'CT_INFO',
|
||||
CT_WARNING: 'CT_WARNING',
|
||||
CT_ERROR: 'CT_ERROR',
|
||||
} as const;
|
||||
|
||||
/**
|
||||
* The supported severity levels of trace events.
|
||||
*/
|
||||
export type _grpc_channelz_v1_ChannelTraceEvent_Severity =
|
||||
| 'CT_UNKNOWN'
|
||||
| 0
|
||||
| 'CT_INFO'
|
||||
| 1
|
||||
| 'CT_WARNING'
|
||||
| 2
|
||||
| 'CT_ERROR'
|
||||
| 3
|
||||
|
||||
/**
|
||||
* The supported severity levels of trace events.
|
||||
*/
|
||||
export type _grpc_channelz_v1_ChannelTraceEvent_Severity__Output = typeof _grpc_channelz_v1_ChannelTraceEvent_Severity[keyof typeof _grpc_channelz_v1_ChannelTraceEvent_Severity]
|
||||
|
||||
/**
|
||||
* A trace event is an interesting thing that happened to a channel or
|
||||
|
@ -28,7 +46,7 @@ export interface ChannelTraceEvent {
|
|||
/**
|
||||
* the severity of the trace event
|
||||
*/
|
||||
'severity'?: (_grpc_channelz_v1_ChannelTraceEvent_Severity | keyof typeof _grpc_channelz_v1_ChannelTraceEvent_Severity);
|
||||
'severity'?: (_grpc_channelz_v1_ChannelTraceEvent_Severity);
|
||||
/**
|
||||
* When this event occurred.
|
||||
*/
|
||||
|
@ -56,7 +74,7 @@ export interface ChannelTraceEvent__Output {
|
|||
/**
|
||||
* the severity of the trace event
|
||||
*/
|
||||
'severity': (keyof typeof _grpc_channelz_v1_ChannelTraceEvent_Severity);
|
||||
'severity': (_grpc_channelz_v1_ChannelTraceEvent_Severity__Output);
|
||||
/**
|
||||
* When this event occurred.
|
||||
*/
|
||||
|
|
|
@ -43,9 +43,7 @@ import {
|
|||
loadPackageDefinition,
|
||||
makeClientConstructor,
|
||||
MethodDefinition,
|
||||
ProtobufTypeDefinition,
|
||||
Serialize,
|
||||
ServiceClientConstructor,
|
||||
ServiceDefinition,
|
||||
} from './make-client';
|
||||
import { Metadata, MetadataOptions, MetadataValue } from './metadata';
|
||||
|
|
|
@ -20,12 +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,
|
||||
QueuePicker,
|
||||
} from './picker';
|
||||
import { UnavailablePicker, Picker, QueuePicker } from './picker';
|
||||
import { Metadata } from './metadata';
|
||||
import { Status, LogVerbosity, Propagate } from './constants';
|
||||
import { FilterStackFactory } from './filter-stack';
|
||||
|
@ -36,13 +31,12 @@ 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 {
|
||||
|
@ -55,22 +49,10 @@ import {
|
|||
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';
|
||||
|
|
|
@ -24,7 +24,6 @@ import {
|
|||
createChildChannelControlHelper,
|
||||
registerLoadBalancerType,
|
||||
} from './experimental';
|
||||
import { BaseFilter, Filter, FilterFactory } from './filter';
|
||||
import {
|
||||
getFirstUsableConfig,
|
||||
LoadBalancer,
|
||||
|
@ -32,15 +31,7 @@ import {
|
|||
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,
|
||||
|
@ -174,6 +165,14 @@ export class OutlierDetectionLoadBalancingConfig
|
|||
failurePercentageEjection: Partial<FailurePercentageEjectionConfig> | null,
|
||||
private readonly childPolicy: LoadBalancingConfig[]
|
||||
) {
|
||||
if (
|
||||
childPolicy.length > 0 &&
|
||||
childPolicy[0].getLoadBalancerName() === 'pick_first'
|
||||
) {
|
||||
throw new Error(
|
||||
'outlier_detection LB policy cannot have a pick_first child policy'
|
||||
);
|
||||
}
|
||||
this.intervalMs = intervalMs ?? 10_000;
|
||||
this.baseEjectionTimeMs = baseEjectionTimeMs ?? 30_000;
|
||||
this.maxEjectionTimeMs = maxEjectionTimeMs ?? 300_000;
|
||||
|
|
|
@ -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';
|
||||
|
|
|
@ -26,7 +26,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';
|
||||
|
@ -55,7 +54,6 @@ export class LoadBalancingCall implements Call {
|
|||
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;
|
||||
|
@ -262,10 +260,12 @@ export class LoadBalancingCall implements Call {
|
|||
pickResult.status!.code,
|
||||
pickResult.status!.details
|
||||
);
|
||||
this.outputStatus(
|
||||
{ code, details, metadata: pickResult.status!.metadata },
|
||||
'DROP'
|
||||
);
|
||||
setImmediate(() => {
|
||||
this.outputStatus(
|
||||
{ code, details, metadata: pickResult.status!.metadata },
|
||||
'DROP'
|
||||
);
|
||||
});
|
||||
break;
|
||||
case PickResultType.TRANSIENT_FAILURE:
|
||||
if (this.metadata.getOptions().waitForReady) {
|
||||
|
@ -275,10 +275,12 @@ export class LoadBalancingCall implements Call {
|
|||
pickResult.status!.code,
|
||||
pickResult.status!.details
|
||||
);
|
||||
this.outputStatus(
|
||||
{ code, details, metadata: pickResult.status!.metadata },
|
||||
'PROCESSED'
|
||||
);
|
||||
setImmediate(() => {
|
||||
this.outputStatus(
|
||||
{ code, details, metadata: pickResult.status!.metadata },
|
||||
'PROCESSED'
|
||||
);
|
||||
});
|
||||
}
|
||||
break;
|
||||
case PickResultType.QUEUE:
|
||||
|
|
|
@ -28,7 +28,7 @@ import { Metadata } from './metadata';
|
|||
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) {
|
||||
constructor(options: ChannelOptions) {
|
||||
super();
|
||||
if ('grpc.max_send_message_length' in options) {
|
||||
this.maxSendMessageSize = options['grpc.max_send_message_length']!;
|
||||
|
|
|
@ -230,11 +230,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 */
|
||||
|
|
|
@ -286,7 +286,9 @@ class DnsResolver implements Resolver {
|
|||
} catch (err) {
|
||||
this.latestServiceConfigError = {
|
||||
code: Status.UNAVAILABLE,
|
||||
details: 'Parsing service config failed',
|
||||
details: `Parsing service config failed with error ${
|
||||
(err as Error).message
|
||||
}`,
|
||||
metadata: new Metadata(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -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
|
||||
) {
|
||||
|
|
|
@ -27,7 +27,6 @@ import { LogVerbosity, Propagate, Status } from './constants';
|
|||
import {
|
||||
Deadline,
|
||||
deadlineToString,
|
||||
getDeadlineTimeoutString,
|
||||
getRelativeTimeout,
|
||||
minDeadline,
|
||||
} from './deadline';
|
||||
|
|
|
@ -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,10 @@ 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. */
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore noUnusedLocals
|
||||
private trailingMetadata: Metadata;
|
||||
|
||||
constructor(
|
||||
|
@ -419,7 +423,7 @@ export class Http2ServerCallStream<
|
|||
constructor(
|
||||
private stream: http2.ServerHttp2Stream,
|
||||
private handler: Handler<RequestType, ResponseType>,
|
||||
private options: ChannelOptions
|
||||
options: ChannelOptions
|
||||
) {
|
||||
super();
|
||||
|
||||
|
|
|
@ -150,10 +150,6 @@ interface ChannelzSessionInfo {
|
|||
lastMessageReceivedTimestamp: Date | null;
|
||||
}
|
||||
|
||||
interface ChannelzListenerInfo {
|
||||
ref: SocketRef;
|
||||
}
|
||||
|
||||
export class Server {
|
||||
private http2ServerList: {
|
||||
server: http2.Http2Server | http2.Http2SecureServer;
|
||||
|
@ -1207,7 +1203,7 @@ async function handleUnary<RequestType, ResponseType>(
|
|||
}
|
||||
);
|
||||
} catch (err) {
|
||||
call.sendError(err as ServerErrorResponse)
|
||||
call.sendError(err as ServerErrorResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1264,7 +1260,7 @@ async function handleServerStreaming<RequestType, ResponseType>(
|
|||
|
||||
handler.func(stream);
|
||||
} catch (err) {
|
||||
call.sendError(err as ServerErrorResponse)
|
||||
call.sendError(err as ServerErrorResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -23,8 +23,6 @@ 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,
|
||||
|
@ -35,9 +33,6 @@ 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
|
||||
*/
|
||||
|
|
|
@ -67,10 +67,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 {
|
||||
|
@ -135,11 +131,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;
|
||||
|
@ -150,7 +141,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 = [
|
||||
|
@ -584,7 +580,13 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
|||
private session: http2.ClientHttp2Session | null = null;
|
||||
private isShutdown = false;
|
||||
constructor(private channelTarget: GrpcUri) {}
|
||||
private trace(text: string) {}
|
||||
private trace(text: string) {
|
||||
logging.trace(
|
||||
LogVerbosity.DEBUG,
|
||||
TRACER_NAME,
|
||||
this.channelTarget + ' ' + text
|
||||
);
|
||||
}
|
||||
private createSession(
|
||||
address: SubchannelAddress,
|
||||
credentials: ChannelCredentials,
|
||||
|
@ -702,7 +704,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', () => {
|
||||
|
|
|
@ -19,17 +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';
|
||||
|
|
|
@ -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';
|
||||
|
||||
|
|
|
@ -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: [
|
||||
|
|
|
@ -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;
|
||||
|
@ -372,6 +371,16 @@ describe('Outlier detection config validation', () => {
|
|||
}, /failure_percentage_ejection\.enforcement_percentage parse error: value out of range for percentage/);
|
||||
});
|
||||
});
|
||||
describe('child_policy', () => {
|
||||
it('Should reject a pick_first child_policy', () => {
|
||||
const loadBalancingConfig = {
|
||||
child_policy: [{ pick_first: {} }],
|
||||
};
|
||||
assert.throws(() => {
|
||||
OutlierDetectionLoadBalancingConfig.createFromJson(loadBalancingConfig);
|
||||
}, /outlier_detection LB policy cannot have a pick_first child policy/);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('Outlier detection', () => {
|
||||
|
|
|
@ -717,7 +717,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 });
|
||||
|
|
|
@ -16,7 +16,8 @@
|
|||
"module": "commonjs",
|
||||
"resolveJsonModule": true,
|
||||
"incremental": true,
|
||||
"types": ["mocha"]
|
||||
"types": ["mocha"],
|
||||
"noUnusedLocals": true
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
|
|
Loading…
Reference in New Issue