mirror of https://github.com/grpc/grpc-node.git
lint and formatting fixes
This commit is contained in:
parent
57c18382d8
commit
c5428c5733
|
@ -190,7 +190,7 @@ class SecureChannelCredentialsImpl extends ChannelCredentials {
|
|||
ca: rootCerts || undefined,
|
||||
key: privateKey || undefined,
|
||||
cert: certChain || undefined,
|
||||
ciphers: CIPHER_SUITES
|
||||
ciphers: CIPHER_SUITES,
|
||||
});
|
||||
this.connectionOptions = { secureContext };
|
||||
if (verifyOptions && verifyOptions.checkServerIdentity) {
|
||||
|
|
|
@ -143,7 +143,9 @@ export class ChannelImplementation implements Channel {
|
|||
) {
|
||||
/* The global boolean parameter to getSubchannelPool has the inverse meaning to what
|
||||
* the grpc.use_local_subchannel_pool channel option means. */
|
||||
this.subchannelPool = getSubchannelPool((options['grpc.use_local_subchannel_pool'] ?? 0) === 0);
|
||||
this.subchannelPool = getSubchannelPool(
|
||||
(options['grpc.use_local_subchannel_pool'] ?? 0) === 0
|
||||
);
|
||||
const channelControlHelper: ChannelControlHelper = {
|
||||
createSubchannel: (
|
||||
subchannelAddress: SubchannelAddress,
|
||||
|
|
|
@ -30,7 +30,11 @@ import {
|
|||
UnavailablePicker,
|
||||
} from './picker';
|
||||
import { LoadBalancingConfig } from './load-balancing-config';
|
||||
import { Subchannel, ConnectivityStateListener, SubchannelAddress } from './subchannel';
|
||||
import {
|
||||
Subchannel,
|
||||
ConnectivityStateListener,
|
||||
SubchannelAddress,
|
||||
} from './subchannel';
|
||||
import * as logging from './logging';
|
||||
import { LogVerbosity } from './constants';
|
||||
|
||||
|
|
|
@ -30,7 +30,11 @@ import {
|
|||
UnavailablePicker,
|
||||
} from './picker';
|
||||
import { LoadBalancingConfig } from './load-balancing-config';
|
||||
import { Subchannel, ConnectivityStateListener, SubchannelAddress } from './subchannel';
|
||||
import {
|
||||
Subchannel,
|
||||
ConnectivityStateListener,
|
||||
SubchannelAddress,
|
||||
} from './subchannel';
|
||||
|
||||
const TYPE_NAME = 'round_robin';
|
||||
|
||||
|
|
|
@ -223,8 +223,9 @@ class DnsResolver implements Resolver {
|
|||
this.pendingResultPromise.then(
|
||||
([addressList, txtRecord]) => {
|
||||
this.pendingResultPromise = null;
|
||||
const ip4Addresses: dns.LookupAddress[] = addressList
|
||||
.filter(addr => addr.family === 4);
|
||||
const ip4Addresses: dns.LookupAddress[] = addressList.filter(
|
||||
addr => addr.family === 4
|
||||
);
|
||||
let ip6Addresses: dns.LookupAddress[];
|
||||
if (semver.satisfies(process.version, IPV6_SUPPORT_RANGE)) {
|
||||
ip6Addresses = addressList.filter(addr => addr.family === 6);
|
||||
|
@ -234,10 +235,16 @@ class DnsResolver implements Resolver {
|
|||
const allAddresses: SubchannelAddress[] = mergeArrays(
|
||||
ip4Addresses,
|
||||
ip6Addresses
|
||||
).map(addr => {return {host: addr.address, port: +this.port!};});
|
||||
const allAddressesString: string = '[' + allAddresses.map(addr => addr.host + ':' + addr.port).join(',') + ']';
|
||||
).map(addr => ({ host: addr.address, port: +this.port! }));
|
||||
const allAddressesString: string =
|
||||
'[' +
|
||||
allAddresses.map(addr => addr.host + ':' + addr.port).join(',') +
|
||||
']';
|
||||
trace(
|
||||
'Resolved addresses for target ' + this.target + ': ' + allAddressesString
|
||||
'Resolved addresses for target ' +
|
||||
this.target +
|
||||
': ' +
|
||||
allAddressesString
|
||||
);
|
||||
if (allAddresses.length === 0) {
|
||||
this.listener.onError(this.defaultResolutionError);
|
||||
|
|
|
@ -75,7 +75,7 @@ export abstract class ServerCredentials {
|
|||
cert,
|
||||
key,
|
||||
requestCert: checkClientCertificate,
|
||||
ciphers: CIPHER_SUITES
|
||||
ciphers: CIPHER_SUITES,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,11 +203,16 @@ export class Server {
|
|||
const options: ListenOptions = { host: url.hostname, port: +url.port };
|
||||
const serverOptions: http2.ServerOptions = {};
|
||||
if ('grpc.max_concurrent_streams' in this.options) {
|
||||
serverOptions.settings = {maxConcurrentStreams: this.options['grpc.max_concurrent_streams']};
|
||||
serverOptions.settings = {
|
||||
maxConcurrentStreams: this.options['grpc.max_concurrent_streams'],
|
||||
};
|
||||
}
|
||||
|
||||
if (creds._isSecure()) {
|
||||
const secureServerOptions = Object.assign(serverOptions, creds._getSettings()!);
|
||||
const secureServerOptions = Object.assign(
|
||||
serverOptions,
|
||||
creds._getSettings()!
|
||||
);
|
||||
this.http2Server = http2.createSecureServer(secureServerOptions);
|
||||
} else {
|
||||
this.http2Server = http2.createServer(serverOptions);
|
||||
|
|
|
@ -16,7 +16,11 @@
|
|||
*/
|
||||
|
||||
import { ChannelOptions, channelOptionsEqual } from './channel-options';
|
||||
import { Subchannel, SubchannelAddress, subchannelAddressEqual } from './subchannel';
|
||||
import {
|
||||
Subchannel,
|
||||
SubchannelAddress,
|
||||
subchannelAddressEqual,
|
||||
} from './subchannel';
|
||||
import { ChannelCredentials } from './channel-credentials';
|
||||
|
||||
// 10 seconds in milliseconds. This value is arbitrary.
|
||||
|
@ -120,7 +124,10 @@ export class SubchannelPool {
|
|||
const subchannelObjArray = this.pool[channelTarget];
|
||||
for (const subchannelObj of subchannelObjArray) {
|
||||
if (
|
||||
subchannelAddressEqual(subchannelTarget, subchannelObj.subchannelAddress) &&
|
||||
subchannelAddressEqual(
|
||||
subchannelTarget,
|
||||
subchannelObj.subchannelAddress
|
||||
) &&
|
||||
channelOptionsEqual(
|
||||
channelArguments,
|
||||
subchannelObj.channelArguments
|
||||
|
|
|
@ -86,8 +86,15 @@ export interface SubchannelAddress {
|
|||
path?: string;
|
||||
}
|
||||
|
||||
export function subchannelAddressEqual(address1: SubchannelAddress, address2: SubchannelAddress) : boolean {
|
||||
return address1.port === address2.port && address1.host === address2.host && address1.path === address2.path;
|
||||
export function subchannelAddressEqual(
|
||||
address1: SubchannelAddress,
|
||||
address2: SubchannelAddress
|
||||
): boolean {
|
||||
return (
|
||||
address1.port === address2.port &&
|
||||
address1.host === address2.host &&
|
||||
address1.path === address2.path
|
||||
);
|
||||
}
|
||||
|
||||
export class Subchannel {
|
||||
|
@ -194,7 +201,7 @@ export class Subchannel {
|
|||
clearTimeout(this.keepaliveTimeoutId);
|
||||
const backoffOptions: BackoffOptions = {
|
||||
initialDelay: options['grpc.initial_reconnect_backoff_ms'],
|
||||
maxDelay: options['grpc.max_reconnect_backoff_ms']
|
||||
maxDelay: options['grpc.max_reconnect_backoff_ms'],
|
||||
};
|
||||
this.backoffTimeout = new BackoffTimeout(() => {
|
||||
if (this.continueConnecting) {
|
||||
|
@ -276,7 +283,10 @@ export class Subchannel {
|
|||
connectionOptions.servername = getDefaultAuthority(this.channelTarget);
|
||||
}
|
||||
}
|
||||
connectionOptions = Object.assign(connectionOptions, this.subchannelAddress);
|
||||
connectionOptions = Object.assign(
|
||||
connectionOptions,
|
||||
this.subchannelAddress
|
||||
);
|
||||
/* 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
|
||||
|
|
|
@ -17,7 +17,8 @@
|
|||
|
||||
import * as fs from 'fs';
|
||||
|
||||
export const CIPHER_SUITES: string | undefined = process.env.GRPC_SSL_CIPHER_SUITES;
|
||||
export const CIPHER_SUITES: string | undefined =
|
||||
process.env.GRPC_SSL_CIPHER_SUITES;
|
||||
|
||||
const DEFAULT_ROOTS_FILE_PATH = process.env.GRPC_DEFAULT_SSL_ROOTS_FILE_PATH;
|
||||
|
||||
|
|
|
@ -38,7 +38,11 @@ describe('Name Resolver', () => {
|
|||
serviceConfig: ServiceConfig | null,
|
||||
serviceConfigError: StatusObject | null
|
||||
) => {
|
||||
assert(addressList.some(addr => addr.host === '127.0.0.1' && addr.port === 50051));
|
||||
assert(
|
||||
addressList.some(
|
||||
addr => addr.host === '127.0.0.1' && addr.port === 50051
|
||||
)
|
||||
);
|
||||
// We would check for the IPv6 address but it needs to be omitted on some Node versions
|
||||
done();
|
||||
},
|
||||
|
@ -57,7 +61,11 @@ describe('Name Resolver', () => {
|
|||
serviceConfig: ServiceConfig | null,
|
||||
serviceConfigError: StatusObject | null
|
||||
) => {
|
||||
assert(addressList.some(addr => addr.host === '127.0.0.1' && addr.port === 443));
|
||||
assert(
|
||||
addressList.some(
|
||||
addr => addr.host === '127.0.0.1' && addr.port === 443
|
||||
)
|
||||
);
|
||||
// We would check for the IPv6 address but it needs to be omitted on some Node versions
|
||||
done();
|
||||
},
|
||||
|
@ -76,7 +84,11 @@ describe('Name Resolver', () => {
|
|||
serviceConfig: ServiceConfig | null,
|
||||
serviceConfigError: StatusObject | null
|
||||
) => {
|
||||
assert(addressList.some(addr => addr.host === '1.2.3.4' && addr.port === 443));
|
||||
assert(
|
||||
addressList.some(
|
||||
addr => addr.host === '1.2.3.4' && addr.port === 443
|
||||
)
|
||||
);
|
||||
// We would check for the IPv6 address but it needs to be omitted on some Node versions
|
||||
done();
|
||||
},
|
||||
|
@ -95,7 +107,9 @@ describe('Name Resolver', () => {
|
|||
serviceConfig: ServiceConfig | null,
|
||||
serviceConfigError: StatusObject | null
|
||||
) => {
|
||||
assert(addressList.some(addr => addr.host === '::1' && addr.port === 443));
|
||||
assert(
|
||||
addressList.some(addr => addr.host === '::1' && addr.port === 443)
|
||||
);
|
||||
// We would check for the IPv6 address but it needs to be omitted on some Node versions
|
||||
done();
|
||||
},
|
||||
|
@ -114,7 +128,9 @@ describe('Name Resolver', () => {
|
|||
serviceConfig: ServiceConfig | null,
|
||||
serviceConfigError: StatusObject | null
|
||||
) => {
|
||||
assert(addressList.some(addr => addr.host === '::1' && addr.port === 50051));
|
||||
assert(
|
||||
addressList.some(addr => addr.host === '::1' && addr.port === 50051)
|
||||
);
|
||||
// We would check for the IPv6 address but it needs to be omitted on some Node versions
|
||||
done();
|
||||
},
|
||||
|
@ -223,7 +239,7 @@ describe('Name Resolver', () => {
|
|||
serviceConfig: ServiceConfig | null,
|
||||
serviceConfigError: StatusObject | null
|
||||
) => {
|
||||
assert(addressList.some(addr => addr.path = 'socket'));
|
||||
assert(addressList.some(addr => (addr.path = 'socket')));
|
||||
done();
|
||||
},
|
||||
onError: (error: StatusObject) => {
|
||||
|
@ -241,7 +257,7 @@ describe('Name Resolver', () => {
|
|||
serviceConfig: ServiceConfig | null,
|
||||
serviceConfigError: StatusObject | null
|
||||
) => {
|
||||
assert(addressList.some(addr => addr.path = '/tmp/socket'));
|
||||
assert(addressList.some(addr => (addr.path = '/tmp/socket')));
|
||||
done();
|
||||
},
|
||||
onError: (error: StatusObject) => {
|
||||
|
|
Loading…
Reference in New Issue