mirror of https://github.com/grpc/grpc-node.git
grpc-js: Reformat files and fix lint errors
This commit is contained in:
parent
220a70289c
commit
66bcc7a2cc
|
@ -191,7 +191,7 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
||||||
) {
|
) {
|
||||||
super();
|
super();
|
||||||
this.connectionOptions = {
|
this.connectionOptions = {
|
||||||
secureContext
|
secureContext,
|
||||||
};
|
};
|
||||||
// Node asserts that this option is a function, so we cannot pass undefined
|
// Node asserts that this option is a function, so we cannot pass undefined
|
||||||
if (verifyOptions?.checkServerIdentity) {
|
if (verifyOptions?.checkServerIdentity) {
|
||||||
|
@ -220,8 +220,9 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
||||||
if (other instanceof SecureChannelCredentialsImpl) {
|
if (other instanceof SecureChannelCredentialsImpl) {
|
||||||
return (
|
return (
|
||||||
this.secureContext === other.secureContext &&
|
this.secureContext === other.secureContext &&
|
||||||
this.verifyOptions.checkServerIdentity === other.verifyOptions.checkServerIdentity
|
this.verifyOptions.checkServerIdentity ===
|
||||||
);
|
other.verifyOptions.checkServerIdentity
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,11 +342,16 @@ export class Client {
|
||||||
if (status.code === Status.OK) {
|
if (status.code === Status.OK) {
|
||||||
if (responseMessage === null) {
|
if (responseMessage === null) {
|
||||||
const callerStack = getErrorStackString(callerStackError!);
|
const callerStack = getErrorStackString(callerStackError!);
|
||||||
callProperties.callback!(callErrorFromStatus({
|
callProperties.callback!(
|
||||||
code: Status.INTERNAL,
|
callErrorFromStatus(
|
||||||
details: 'No message received',
|
{
|
||||||
metadata: status.metadata
|
code: Status.INTERNAL,
|
||||||
}, callerStack));
|
details: 'No message received',
|
||||||
|
metadata: status.metadata,
|
||||||
|
},
|
||||||
|
callerStack
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
callProperties.callback!(null, responseMessage);
|
callProperties.callback!(null, responseMessage);
|
||||||
}
|
}
|
||||||
|
@ -470,11 +475,16 @@ export class Client {
|
||||||
if (status.code === Status.OK) {
|
if (status.code === Status.OK) {
|
||||||
if (responseMessage === null) {
|
if (responseMessage === null) {
|
||||||
const callerStack = getErrorStackString(callerStackError!);
|
const callerStack = getErrorStackString(callerStackError!);
|
||||||
callProperties.callback!(callErrorFromStatus({
|
callProperties.callback!(
|
||||||
code: Status.INTERNAL,
|
callErrorFromStatus(
|
||||||
details: 'No message received',
|
{
|
||||||
metadata: status.metadata
|
code: Status.INTERNAL,
|
||||||
}, callerStack));
|
details: 'No message received',
|
||||||
|
metadata: status.metadata,
|
||||||
|
},
|
||||||
|
callerStack
|
||||||
|
)
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
callProperties.callback!(null, responseMessage);
|
callProperties.callback!(null, responseMessage);
|
||||||
}
|
}
|
||||||
|
|
|
@ -305,8 +305,9 @@ 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(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);
|
||||||
|
|
|
@ -39,7 +39,16 @@ import { GrpcUri, parseUri, uriToString } from './uri-parser';
|
||||||
import { ServerSurfaceCall } from './server-call';
|
import { ServerSurfaceCall } from './server-call';
|
||||||
|
|
||||||
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 { LoadBalancingCall } from './load-balancing-call';
|
import { LoadBalancingCall } from './load-balancing-call';
|
||||||
import { CallCredentials } from './call-credentials';
|
import { CallCredentials } from './call-credentials';
|
||||||
import { Call, CallStreamOptions, StatusObject } from './call-interface';
|
import { Call, CallStreamOptions, StatusObject } from './call-interface';
|
||||||
|
|
|
@ -31,12 +31,7 @@ import {
|
||||||
validateLoadBalancingConfig,
|
validateLoadBalancingConfig,
|
||||||
} from './load-balancer';
|
} from './load-balancer';
|
||||||
import { ChildLoadBalancerHandler } from './load-balancer-child-handler';
|
import { ChildLoadBalancerHandler } from './load-balancer-child-handler';
|
||||||
import {
|
import { PickArgs, Picker, PickResult, PickResultType } from './picker';
|
||||||
PickArgs,
|
|
||||||
Picker,
|
|
||||||
PickResult,
|
|
||||||
PickResultType,
|
|
||||||
} from './picker';
|
|
||||||
import {
|
import {
|
||||||
SubchannelAddress,
|
SubchannelAddress,
|
||||||
subchannelAddressToString,
|
subchannelAddressToString,
|
||||||
|
@ -170,8 +165,13 @@ export class OutlierDetectionLoadBalancingConfig
|
||||||
failurePercentageEjection: Partial<FailurePercentageEjectionConfig> | null,
|
failurePercentageEjection: Partial<FailurePercentageEjectionConfig> | null,
|
||||||
private readonly childPolicy: LoadBalancingConfig[]
|
private readonly childPolicy: LoadBalancingConfig[]
|
||||||
) {
|
) {
|
||||||
if (childPolicy.length > 0 && childPolicy[0].getLoadBalancerName() === 'pick_first') {
|
if (
|
||||||
throw new Error('outlier_detection LB policy cannot have a pick_first child policy');
|
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.intervalMs = intervalMs ?? 10_000;
|
||||||
this.baseEjectionTimeMs = baseEjectionTimeMs ?? 30_000;
|
this.baseEjectionTimeMs = baseEjectionTimeMs ?? 30_000;
|
||||||
|
|
|
@ -256,18 +256,30 @@ export class LoadBalancingCall implements Call {
|
||||||
);
|
);
|
||||||
break;
|
break;
|
||||||
case PickResultType.DROP:
|
case PickResultType.DROP:
|
||||||
const {code, details} = restrictControlPlaneStatusCode(pickResult.status!.code, pickResult.status!.details);
|
const { code, details } = restrictControlPlaneStatusCode(
|
||||||
|
pickResult.status!.code,
|
||||||
|
pickResult.status!.details
|
||||||
|
);
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
this.outputStatus({code, details, metadata: pickResult.status!.metadata}, 'DROP');
|
this.outputStatus(
|
||||||
|
{ code, details, metadata: pickResult.status!.metadata },
|
||||||
|
'DROP'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
case PickResultType.TRANSIENT_FAILURE:
|
case PickResultType.TRANSIENT_FAILURE:
|
||||||
if (this.metadata.getOptions().waitForReady) {
|
if (this.metadata.getOptions().waitForReady) {
|
||||||
this.channel.queueCallForPick(this);
|
this.channel.queueCallForPick(this);
|
||||||
} else {
|
} else {
|
||||||
const {code, details} = restrictControlPlaneStatusCode(pickResult.status!.code, pickResult.status!.details);
|
const { code, details } = restrictControlPlaneStatusCode(
|
||||||
|
pickResult.status!.code,
|
||||||
|
pickResult.status!.details
|
||||||
|
);
|
||||||
setImmediate(() => {
|
setImmediate(() => {
|
||||||
this.outputStatus({code, details, metadata: pickResult.status!.metadata}, 'PROCESSED');
|
this.outputStatus(
|
||||||
|
{ code, details, metadata: pickResult.status!.metadata },
|
||||||
|
'PROCESSED'
|
||||||
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -28,9 +28,7 @@ import { Metadata } from './metadata';
|
||||||
export class MaxMessageSizeFilter extends BaseFilter implements Filter {
|
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(options: ChannelOptions) {
|
||||||
options: ChannelOptions
|
|
||||||
) {
|
|
||||||
super();
|
super();
|
||||||
if ('grpc.max_send_message_length' in options) {
|
if ('grpc.max_send_message_length' in options) {
|
||||||
this.maxSendMessageSize = options['grpc.max_send_message_length']!;
|
this.maxSendMessageSize = options['grpc.max_send_message_length']!;
|
||||||
|
|
|
@ -286,7 +286,9 @@ class DnsResolver implements Resolver {
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
this.latestServiceConfigError = {
|
this.latestServiceConfigError = {
|
||||||
code: Status.UNAVAILABLE,
|
code: Status.UNAVAILABLE,
|
||||||
details: `Parsing service config failed with error ${(err as Error).message}`,
|
details: `Parsing service config failed with error ${
|
||||||
|
(err as Error).message
|
||||||
|
}`,
|
||||||
metadata: new Metadata(),
|
metadata: new Metadata(),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,6 +270,7 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
|
||||||
cancelled: boolean;
|
cancelled: boolean;
|
||||||
/* This field appears to be unsued, but it is actually used in _final, which is assiged from
|
/* This field appears to be unsued, but it is actually used in _final, which is assiged from
|
||||||
* ServerWritableStreamImpl.prototype._final below. */
|
* ServerWritableStreamImpl.prototype._final below. */
|
||||||
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore noUnusedLocals
|
// @ts-ignore noUnusedLocals
|
||||||
private trailingMetadata: Metadata;
|
private trailingMetadata: Metadata;
|
||||||
|
|
||||||
|
|
|
@ -1203,7 +1203,7 @@ async function handleUnary<RequestType, ResponseType>(
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
call.sendError(err as ServerErrorResponse)
|
call.sendError(err as ServerErrorResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1260,7 +1260,7 @@ async function handleServerStreaming<RequestType, ResponseType>(
|
||||||
|
|
||||||
handler.func(stream);
|
handler.func(stream);
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
call.sendError(err as ServerErrorResponse)
|
call.sendError(err as ServerErrorResponse);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -581,7 +581,11 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
||||||
private isShutdown = false;
|
private isShutdown = false;
|
||||||
constructor(private channelTarget: GrpcUri) {}
|
constructor(private channelTarget: GrpcUri) {}
|
||||||
private trace(text: string) {
|
private trace(text: string) {
|
||||||
logging.trace(LogVerbosity.DEBUG, TRACER_NAME, this.channelTarget + ' ' + text);
|
logging.trace(
|
||||||
|
LogVerbosity.DEBUG,
|
||||||
|
TRACER_NAME,
|
||||||
|
this.channelTarget + ' ' + text
|
||||||
|
);
|
||||||
}
|
}
|
||||||
private createSession(
|
private createSession(
|
||||||
address: SubchannelAddress,
|
address: SubchannelAddress,
|
||||||
|
|
|
@ -173,23 +173,18 @@ describe('ChannelCredentials usage', () => {
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
server.bindAsync(
|
server.bindAsync('localhost:0', serverCreds, (err, port) => {
|
||||||
'localhost:0',
|
if (err) {
|
||||||
serverCreds,
|
reject(err);
|
||||||
(err, port) => {
|
return;
|
||||||
if (err) {
|
|
||||||
reject(err);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
client = new echoService(
|
|
||||||
`localhost:${port}`,
|
|
||||||
combinedCreds,
|
|
||||||
{'grpc.ssl_target_name_override': 'foo.test.google.fr', 'grpc.default_authority': 'foo.test.google.fr'}
|
|
||||||
);
|
|
||||||
server.start();
|
|
||||||
resolve();
|
|
||||||
}
|
}
|
||||||
);
|
client = new echoService(`localhost:${port}`, combinedCreds, {
|
||||||
|
'grpc.ssl_target_name_override': 'foo.test.google.fr',
|
||||||
|
'grpc.default_authority': 'foo.test.google.fr',
|
||||||
|
});
|
||||||
|
server.start();
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
after(() => {
|
after(() => {
|
||||||
|
|
|
@ -19,7 +19,7 @@ import * as assert from 'assert';
|
||||||
import * as path from 'path';
|
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';
|
||||||
|
|
||||||
function multiDone(done: Mocha.Done, target: number) {
|
function multiDone(done: Mocha.Done, target: number) {
|
||||||
let count = 0;
|
let count = 0;
|
||||||
|
@ -374,7 +374,7 @@ describe('Outlier detection config validation', () => {
|
||||||
describe('child_policy', () => {
|
describe('child_policy', () => {
|
||||||
it('Should reject a pick_first child_policy', () => {
|
it('Should reject a pick_first child_policy', () => {
|
||||||
const loadBalancingConfig = {
|
const loadBalancingConfig = {
|
||||||
child_policy: [{pick_first: {}}]
|
child_policy: [{ pick_first: {} }],
|
||||||
};
|
};
|
||||||
assert.throws(() => {
|
assert.throws(() => {
|
||||||
OutlierDetectionLoadBalancingConfig.createFromJson(loadBalancingConfig);
|
OutlierDetectionLoadBalancingConfig.createFromJson(loadBalancingConfig);
|
||||||
|
|
Loading…
Reference in New Issue