Skip to content

Commit

Permalink
Merge pull request #2679 from murgatroid99/grpc-js_1.10_format
Browse files Browse the repository at this point in the history
grpc-js: Run code formatter, fix one lint error
  • Loading branch information
murgatroid99 authored Feb 27, 2024
2 parents 513a61a + 6c2bc59 commit 210967f
Show file tree
Hide file tree
Showing 19 changed files with 698 additions and 354 deletions.
4 changes: 3 additions & 1 deletion packages/grpc-js/src/backoff-timeout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ export class BackoffTimeout {

private runTimer(delay: number) {
this.endTime = this.startTime;
this.endTime.setMilliseconds(this.endTime.getMilliseconds() + this.nextDelay);
this.endTime.setMilliseconds(
this.endTime.getMilliseconds() + this.nextDelay
);
clearTimeout(this.timerId);
this.timerId = setTimeout(() => {
this.callback();
Expand Down
11 changes: 8 additions & 3 deletions packages/grpc-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ export {
ServiceDefinition,
UntypedHandleCall,
UntypedServiceImplementation,
VerifyOptions
VerifyOptions,
};

/**** Server ****/
Expand Down Expand Up @@ -263,7 +263,12 @@ export { getChannelzServiceDefinition, getChannelzHandlers } from './channelz';

export { addAdminServicesToServer } from './admin';

export { ServiceConfig, LoadBalancingConfig, MethodConfig, RetryPolicy } from './service-config';
export {
ServiceConfig,
LoadBalancingConfig,
MethodConfig,
RetryPolicy,
} from './service-config';

export {
ServerListener,
Expand All @@ -274,7 +279,7 @@ export {
ResponderBuilder,
ServerInterceptingCallInterface,
ServerInterceptingCall,
ServerInterceptor
ServerInterceptor,
} from './server-interceptors';

import * as experimental from './experimental';
Expand Down
8 changes: 6 additions & 2 deletions packages/grpc-js/src/internal-channel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -583,7 +583,8 @@ export class InternalChannel {
return;
}
const now = new Date();
const timeSinceLastActivity = now.valueOf() - this.lastActivityTimestamp.valueOf();
const timeSinceLastActivity =
now.valueOf() - this.lastActivityTimestamp.valueOf();
if (timeSinceLastActivity >= this.idleTimeoutMs) {
this.trace(
'Idle timer triggered after ' +
Expand All @@ -603,7 +604,10 @@ export class InternalChannel {
}

private maybeStartIdleTimer() {
if (this.connectivityState !== ConnectivityState.SHUTDOWN && !this.idleTimer) {
if (
this.connectivityState !== ConnectivityState.SHUTDOWN &&
!this.idleTimer
) {
this.startIdleTimeout(this.idleTimeoutMs);
}
}
Expand Down
23 changes: 19 additions & 4 deletions packages/grpc-js/src/load-balancer-pick-first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,12 @@ export class PickFirstLoadBalancer implements LoadBalancer {
keepaliveTime,
errorMessage
) => {
this.onSubchannelStateUpdate(subchannel, previousState, newState, errorMessage);
this.onSubchannelStateUpdate(
subchannel,
previousState,
newState,
errorMessage
);
};

private pickedSubchannelHealthListener: HealthListener = () =>
Expand Down Expand Up @@ -275,7 +280,9 @@ export class PickFirstLoadBalancer implements LoadBalancer {
if (this.stickyTransientFailureMode) {
this.updateState(
ConnectivityState.TRANSIENT_FAILURE,
new UnavailablePicker({details: `No connection established. Last error: ${this.lastError}`})
new UnavailablePicker({
details: `No connection established. Last error: ${this.lastError}`,
})
);
} else {
this.updateState(ConnectivityState.CONNECTING, new QueuePicker(this));
Expand Down Expand Up @@ -441,7 +448,12 @@ export class PickFirstLoadBalancer implements LoadBalancer {

private resetSubchannelList() {
for (const child of this.children) {
if (!(this.currentPick && child.subchannel.realSubchannelEquals(this.currentPick))) {
if (
!(
this.currentPick &&
child.subchannel.realSubchannelEquals(this.currentPick)
)
) {
/* The connectivity state listener is the same whether the subchannel
* is in the list of children or it is the currentPick, so if it is in
* both, removing it here would cause problems. In particular, that
Expand Down Expand Up @@ -523,7 +535,10 @@ export class PickFirstLoadBalancer implements LoadBalancer {
}

exitIdle() {
if (this.currentState === ConnectivityState.IDLE && this.latestAddressList) {
if (
this.currentState === ConnectivityState.IDLE &&
this.latestAddressList
) {
this.connectToAddressList(this.latestAddressList);
}
}
Expand Down
4 changes: 3 additions & 1 deletion packages/grpc-js/src/load-balancer-round-robin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ export class RoundRobinLoadBalancer implements LoadBalancer {
) {
this.updateState(
ConnectivityState.TRANSIENT_FAILURE,
new UnavailablePicker({details: `No connection established. Last error: ${this.lastError}`})
new UnavailablePicker({
details: `No connection established. Last error: ${this.lastError}`,
})
);
} else {
this.updateState(ConnectivityState.IDLE, new QueuePicker(this));
Expand Down
4 changes: 3 additions & 1 deletion packages/grpc-js/src/load-balancing-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,9 @@ export class LoadBalancingCall implements Call {
* metadata generation finished, we shouldn't do anything with
* it. */
if (this.ended) {
this.trace('Credentials metadata generation finished after call ended');
this.trace(
'Credentials metadata generation finished after call ended'
);
return;
}
finalMetadata.merge(credsMetadata);
Expand Down
13 changes: 12 additions & 1 deletion packages/grpc-js/src/logging.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,18 @@ export function trace(
text: string
): void {
if (isTracerEnabled(tracer)) {
log(severity, new Date().toISOString() + ' | v' + clientVersion + ' ' + pid + ' | ' + tracer + ' | ' + text);
log(
severity,
new Date().toISOString() +
' | v' +
clientVersion +
' ' +
pid +
' | ' +
tracer +
' | ' +
text
);
}
}

Expand Down
9 changes: 7 additions & 2 deletions packages/grpc-js/src/resolver-dns.ts
Original file line number Diff line number Diff line change
Expand Up @@ -335,9 +335,14 @@ class DnsResolver implements Resolver {
if (this.pendingLookupPromise === null) {
if (this.isNextResolutionTimerRunning || this.backoff.isRunning()) {
if (this.isNextResolutionTimerRunning) {
trace('resolution update delayed by "min time between resolutions" rate limit');
trace(
'resolution update delayed by "min time between resolutions" rate limit'
);
} else {
trace('resolution update delayed by backoff timer until ' + this.backoff.getEndTime().toISOString());
trace(
'resolution update delayed by backoff timer until ' +
this.backoff.getEndTime().toISOString()
);
}
this.continueResolving = true;
} else {
Expand Down
7 changes: 5 additions & 2 deletions packages/grpc-js/src/resolving-load-balancer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,8 +223,11 @@ export class ResolvingLoadBalancer implements LoadBalancer {
* In that case, the backoff timer callback will call
* updateResolution */
if (this.backoffTimeout.isRunning()) {
trace('requestReresolution delayed by backoff timer until ' + this.backoffTimeout.getEndTime().toISOString());
this.continueResolving = true;
trace(
'requestReresolution delayed by backoff timer until ' +
this.backoffTimeout.getEndTime().toISOString()
);
this.continueResolving = true;
} else {
this.updateResolution();
}
Expand Down
15 changes: 8 additions & 7 deletions packages/grpc-js/src/server-call.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,7 @@
import { EventEmitter } from 'events';
import { Duplex, Readable, Writable } from 'stream';

import {
Status,
} from './constants';
import { Status } from './constants';
import { Deserialize, Serialize } from './make-client';
import { Metadata } from './metadata';
import { ObjectReadable, ObjectWritable } from './object-stream';
Expand Down Expand Up @@ -56,11 +54,14 @@ export type ServerDuplexStream<RequestType, ResponseType> = ServerSurfaceCall &
ObjectReadable<RequestType> &
ObjectWritable<ResponseType> & { end: (metadata?: Metadata) => void };

export function serverErrorToStatus(error: ServerErrorResponse | ServerStatusResponse, overrideTrailers?: Metadata | undefined): PartialStatusObject {
export function serverErrorToStatus(
error: ServerErrorResponse | ServerStatusResponse,
overrideTrailers?: Metadata | undefined
): PartialStatusObject {
const status: PartialStatusObject = {
code: Status.UNKNOWN,
details: 'message' in error ? error.message : 'Unknown Error',
metadata: overrideTrailers ?? error.metadata ?? null
metadata: overrideTrailers ?? error.metadata ?? null,
};

if (
Expand Down Expand Up @@ -154,7 +155,7 @@ export class ServerWritableStreamImpl<RequestType, ResponseType>
private trailingMetadata: Metadata;
private pendingStatus: PartialStatusObject = {
code: Status.OK,
details: 'OK'
details: 'OK',
};

constructor(
Expand Down Expand Up @@ -224,7 +225,7 @@ export class ServerDuplexStreamImpl<RequestType, ResponseType>
private trailingMetadata: Metadata;
private pendingStatus: PartialStatusObject = {
code: Status.OK,
details: 'OK'
details: 'OK',
};

constructor(
Expand Down
Loading

0 comments on commit 210967f

Please sign in to comment.