Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

grpc-js-xds: Update @types/node and update code for compatibility #2856

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/grpc-js-xds/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"@types/gulp": "^4.0.6",
"@types/gulp-mocha": "0.0.32",
"@types/mocha": "^5.2.6",
"@types/node": "^13.11.1",
"@types/node": ">=20.11.20",
"@types/yargs": "^15.0.5",
"find-free-ports": "^3.1.1",
"gts": "^5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions packages/grpc-js-xds/src/load-balancer-priority.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ export class PriorityLoadBalancer implements LoadBalancer {
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
private picker: Picker;
private childBalancer: ChildLoadBalancerHandler;
private failoverTimer: NodeJS.Timer | null = null;
private deactivationTimer: NodeJS.Timer | null = null;
private failoverTimer: NodeJS.Timeout | null = null;
private deactivationTimer: NodeJS.Timeout | null = null;
private seenReadyOrIdleSinceTransientFailure = false;
constructor(private parent: PriorityLoadBalancer, private name: string, ignoreReresolutionRequests: boolean) {
this.childBalancer = new ChildLoadBalancerHandler(experimental.createChildChannelControlHelper(this.parent.channelControlHelper, {
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js-xds/src/load-balancer-weighted-target.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ export class WeightedTargetLoadBalancer implements LoadBalancer {
private connectivityState: ConnectivityState = ConnectivityState.IDLE;
private picker: Picker;
private childBalancer: ChildLoadBalancerHandler;
private deactivationTimer: NodeJS.Timer | null = null;
private deactivationTimer: NodeJS.Timeout | null = null;
private weight: number = 0;

constructor(private parent: WeightedTargetLoadBalancer, private name: string) {
Expand Down
10 changes: 5 additions & 5 deletions packages/grpc-js-xds/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ interface MatchFieldEvaluator<MatcherType, FieldType> {
isMoreSpecific: (matcher1: MatcherType, matcher2: MatcherType) => boolean;
}

type FieldType<MatcherType> = MatcherType extends CidrRange ? (string | undefined) : MatcherType extends (ConnectionSourceType) ? {localAddress: string, remoteAddress?: (string | undefined)} : MatcherType extends number ? number | undefined : never;
type FieldType<MatcherType> = MatcherType extends CidrRange ? (string | undefined) : MatcherType extends (ConnectionSourceType) ? {localAddress?: (string | undefined), remoteAddress?: (string | undefined)} : MatcherType extends number ? number | undefined : never;

function cidrRangeMatch(range: CidrRange | undefined, address: string | undefined): boolean {
return !range || (!!address && inCidrRange(range, address));
Expand All @@ -506,14 +506,14 @@ function cidrRangeMoreSpecific(range1: CidrRange | undefined, range2: CidrRange
return !!range1 && range1.prefixLen > range2.prefixLen;
}

function sourceTypeMatch(sourceType: ConnectionSourceType, addresses: {localAddress: string, remoteAddress?: (string | undefined)}): boolean {
function sourceTypeMatch(sourceType: ConnectionSourceType, addresses: {localAddress?: (string | undefined), remoteAddress?: (string | undefined)}): boolean {
switch (sourceType) {
case "ANY":
return true;
case "SAME_IP_OR_LOOPBACK":
return !!addresses.remoteAddress && isSameIpOrLoopback(addresses.remoteAddress, addresses.localAddress);
return !!addresses.localAddress && !!addresses.remoteAddress && isSameIpOrLoopback(addresses.remoteAddress, addresses.localAddress);
case "EXTERNAL":
return !!addresses.remoteAddress && !isSameIpOrLoopback(addresses.remoteAddress, addresses.localAddress);
return !!addresses.localAddress && !!addresses.remoteAddress && !isSameIpOrLoopback(addresses.remoteAddress, addresses.localAddress);
}
}

Expand All @@ -523,7 +523,7 @@ const cidrRangeEvaluator: MatchFieldEvaluator<CidrRange | undefined, string | un
isMoreSpecific: cidrRangeMoreSpecific
};

const sourceTypeEvaluator: MatchFieldEvaluator<ConnectionSourceType, {localAddress: string, remoteAddress?: (string | undefined)}> = {
const sourceTypeEvaluator: MatchFieldEvaluator<ConnectionSourceType, {localAddress?: (string | undefined), remoteAddress?: (string | undefined)}> = {
isMatch: sourceTypeMatch,
matcherEqual: (matcher1, matcher2) => matcher1 === matcher2,
isMoreSpecific: (matcher1, matcher2) => matcher1 !== 'ANY' && matcher2 === 'ANY'
Expand Down
4 changes: 2 additions & 2 deletions packages/grpc-js-xds/src/xds-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ export class Watcher<UpdateType> implements ResourceWatcherInterface {
const RESOURCE_TIMEOUT_MS = 15_000;

class ResourceTimer {
private timer: NodeJS.Timer | null = null;
private timer: NodeJS.Timeout | null = null;
private resourceSeen = false;
constructor(private callState: AdsCallState, private type: XdsResourceType, private name: XdsResourceName) {}

Expand Down Expand Up @@ -673,7 +673,7 @@ class ClusterLoadReportMap {
}

class LrsCallState {
private statsTimer: NodeJS.Timer | null = null;
private statsTimer: NodeJS.Timeout | null = null;
private sentInitialMessage = false;
constructor(private client: XdsSingleServerClient, private call: LrsCall, private node: Node) {
call.on('data', (message: LoadStatsResponse__Output) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/grpc-js-xds/test/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const BOOTSTRAP_CONFIG_KEY = 'grpc.TEST_ONLY_DO_NOT_USE_IN_PROD.xds_bootstrap_co

export class XdsTestClient {
private client: EchoTestServiceClient;
private callInterval: NodeJS.Timer;
private callInterval: NodeJS.Timeout;

constructor(target: string, bootstrapInfo: string, creds?: ChannelCredentials | undefined, options?: ChannelOptions) {
this.client = new loadedProtos.grpc.testing.EchoTestService(target, creds ?? credentials.createInsecure(), {...options, [BOOTSTRAP_CONFIG_KEY]: bootstrapInfo});
Expand Down
Loading