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();
|
||||
this.connectionOptions = {
|
||||
secureContext
|
||||
secureContext,
|
||||
};
|
||||
// Node asserts that this option is a function, so we cannot pass undefined
|
||||
if (verifyOptions?.checkServerIdentity) {
|
||||
|
@ -220,8 +220,9 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
|||
if (other instanceof SecureChannelCredentialsImpl) {
|
||||
return (
|
||||
this.secureContext === other.secureContext &&
|
||||
this.verifyOptions.checkServerIdentity === other.verifyOptions.checkServerIdentity
|
||||
);
|
||||
this.verifyOptions.checkServerIdentity ===
|
||||
other.verifyOptions.checkServerIdentity
|
||||
);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -342,11 +342,16 @@ export class Client {
|
|||
if (status.code === Status.OK) {
|
||||
if (responseMessage === null) {
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
callProperties.callback!(callErrorFromStatus({
|
||||
code: Status.INTERNAL,
|
||||
details: 'No message received',
|
||||
metadata: status.metadata
|
||||
}, callerStack));
|
||||
callProperties.callback!(
|
||||
callErrorFromStatus(
|
||||
{
|
||||
code: Status.INTERNAL,
|
||||
details: 'No message received',
|
||||
metadata: status.metadata,
|
||||
},
|
||||
callerStack
|
||||
)
|
||||
);
|
||||
} else {
|
||||
callProperties.callback!(null, responseMessage);
|
||||
}
|
||||
|
@ -470,11 +475,16 @@ export class Client {
|
|||
if (status.code === Status.OK) {
|
||||
if (responseMessage === null) {
|
||||
const callerStack = getErrorStackString(callerStackError!);
|
||||
callProperties.callback!(callErrorFromStatus({
|
||||
code: Status.INTERNAL,
|
||||
details: 'No message received',
|
||||
metadata: status.metadata
|
||||
}, callerStack));
|
||||
callProperties.callback!(
|
||||
callErrorFromStatus(
|
||||
{
|
||||
code: Status.INTERNAL,
|
||||
details: 'No message received',
|
||||
metadata: status.metadata,
|
||||
},
|
||||
callerStack
|
||||
)
|
||||
);
|
||||
} else {
|
||||
callProperties.callback!(null, responseMessage);
|
||||
}
|
||||
|
|
|
@ -305,8 +305,9 @@ export class CompressionFilter extends BaseFilter implements Filter {
|
|||
}
|
||||
|
||||
export class CompressionFilterFactory
|
||||
implements FilterFactory<CompressionFilter> {
|
||||
private sharedFilterConfig: SharedCompressionFilterConfig = {};
|
||||
implements FilterFactory<CompressionFilter>
|
||||
{
|
||||
private sharedFilterConfig: SharedCompressionFilterConfig = {};
|
||||
constructor(channel: Channel, private readonly options: ChannelOptions) {}
|
||||
createFilter(): CompressionFilter {
|
||||
return new CompressionFilter(this.options, this.sharedFilterConfig);
|
||||
|
|
|
@ -39,7 +39,16 @@ import { GrpcUri, parseUri, uriToString } from './uri-parser';
|
|||
import { ServerSurfaceCall } from './server-call';
|
||||
|
||||
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 { CallCredentials } from './call-credentials';
|
||||
import { Call, CallStreamOptions, StatusObject } from './call-interface';
|
||||
|
|
|
@ -31,12 +31,7 @@ import {
|
|||
validateLoadBalancingConfig,
|
||||
} from './load-balancer';
|
||||
import { ChildLoadBalancerHandler } from './load-balancer-child-handler';
|
||||
import {
|
||||
PickArgs,
|
||||
Picker,
|
||||
PickResult,
|
||||
PickResultType,
|
||||
} from './picker';
|
||||
import { PickArgs, Picker, PickResult, PickResultType } from './picker';
|
||||
import {
|
||||
SubchannelAddress,
|
||||
subchannelAddressToString,
|
||||
|
@ -170,8 +165,13 @@ 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');
|
||||
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;
|
||||
|
|
|
@ -256,18 +256,30 @@ export class LoadBalancingCall implements Call {
|
|||
);
|
||||
break;
|
||||
case PickResultType.DROP:
|
||||
const {code, details} = restrictControlPlaneStatusCode(pickResult.status!.code, pickResult.status!.details);
|
||||
const { code, details } = restrictControlPlaneStatusCode(
|
||||
pickResult.status!.code,
|
||||
pickResult.status!.details
|
||||
);
|
||||
setImmediate(() => {
|
||||
this.outputStatus({code, details, metadata: pickResult.status!.metadata}, 'DROP');
|
||||
this.outputStatus(
|
||||
{ code, details, metadata: pickResult.status!.metadata },
|
||||
'DROP'
|
||||
);
|
||||
});
|
||||
break;
|
||||
case PickResultType.TRANSIENT_FAILURE:
|
||||
if (this.metadata.getOptions().waitForReady) {
|
||||
this.channel.queueCallForPick(this);
|
||||
} else {
|
||||
const {code, details} = restrictControlPlaneStatusCode(pickResult.status!.code, pickResult.status!.details);
|
||||
const { code, details } = restrictControlPlaneStatusCode(
|
||||
pickResult.status!.code,
|
||||
pickResult.status!.details
|
||||
);
|
||||
setImmediate(() => {
|
||||
this.outputStatus({code, details, metadata: pickResult.status!.metadata}, 'PROCESSED');
|
||||
this.outputStatus(
|
||||
{ code, details, metadata: pickResult.status!.metadata },
|
||||
'PROCESSED'
|
||||
);
|
||||
});
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -28,9 +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(
|
||||
options: ChannelOptions
|
||||
) {
|
||||
constructor(options: ChannelOptions) {
|
||||
super();
|
||||
if ('grpc.max_send_message_length' in options) {
|
||||
this.maxSendMessageSize = options['grpc.max_send_message_length']!;
|
||||
|
|
|
@ -286,7 +286,9 @@ class DnsResolver implements Resolver {
|
|||
} catch (err) {
|
||||
this.latestServiceConfigError = {
|
||||
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(),
|
||||
};
|
||||
}
|
||||
|
|
|
@ -270,6 +270,7 @@ export class ServerDuplexStreamImpl<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;
|
||||
|
||||
|
|
|
@ -1203,7 +1203,7 @@ async function handleUnary<RequestType, ResponseType>(
|
|||
}
|
||||
);
|
||||
} catch (err) {
|
||||
call.sendError(err as ServerErrorResponse)
|
||||
call.sendError(err as ServerErrorResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1260,7 +1260,7 @@ async function handleServerStreaming<RequestType, ResponseType>(
|
|||
|
||||
handler.func(stream);
|
||||
} catch (err) {
|
||||
call.sendError(err as ServerErrorResponse)
|
||||
call.sendError(err as ServerErrorResponse);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -581,7 +581,11 @@ export class Http2SubchannelConnector implements SubchannelConnector {
|
|||
private isShutdown = false;
|
||||
constructor(private channelTarget: GrpcUri) {}
|
||||
private trace(text: string) {
|
||||
logging.trace(LogVerbosity.DEBUG, TRACER_NAME, this.channelTarget + ' ' + text);
|
||||
logging.trace(
|
||||
LogVerbosity.DEBUG,
|
||||
TRACER_NAME,
|
||||
this.channelTarget + ' ' + text
|
||||
);
|
||||
}
|
||||
private createSession(
|
||||
address: SubchannelAddress,
|
||||
|
|
|
@ -173,23 +173,18 @@ describe('ChannelCredentials usage', () => {
|
|||
},
|
||||
});
|
||||
|
||||
server.bindAsync(
|
||||
'localhost:0',
|
||||
serverCreds,
|
||||
(err, port) => {
|
||||
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();
|
||||
server.bindAsync('localhost:0', serverCreds, (err, port) => {
|
||||
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();
|
||||
});
|
||||
});
|
||||
});
|
||||
after(() => {
|
||||
|
|
|
@ -19,7 +19,7 @@ import * as assert from 'assert';
|
|||
import * as path from 'path';
|
||||
import * as grpc from '../src';
|
||||
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) {
|
||||
let count = 0;
|
||||
|
@ -374,7 +374,7 @@ describe('Outlier detection config validation', () => {
|
|||
describe('child_policy', () => {
|
||||
it('Should reject a pick_first child_policy', () => {
|
||||
const loadBalancingConfig = {
|
||||
child_policy: [{pick_first: {}}]
|
||||
child_policy: [{ pick_first: {} }],
|
||||
};
|
||||
assert.throws(() => {
|
||||
OutlierDetectionLoadBalancingConfig.createFromJson(loadBalancingConfig);
|
||||
|
|
Loading…
Reference in New Issue