Skip to content
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/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"pretest": "npm run generate-types && npm run generate-test-types && npm run compile",
"posttest": "npm run check && madge -c ./build/src",
"generate-types": "proto-loader-gen-types --keepCase --longs String --enums String --defaults --oneofs --includeComments --includeDirs proto/ --include-dirs proto/ proto/xds/ proto/protoc-gen-validate/ -O src/generated/ --grpcLib ../index channelz.proto xds/service/orca/v3/orca.proto",
"generate-test-types": "proto-loader-gen-types --keepCase --longs String --enums String --defaults --oneofs --includeComments --include-dirs test/fixtures/ -O test/generated/ --grpcLib ../../src/index test_service.proto",
"generate-test-types": "proto-loader-gen-types --keepCase --longs String --enums String --defaults --oneofs --includeComments --include-dirs test/fixtures/ -O test/generated/ --grpcLib ../../src/index test_service.proto echo_service.proto",
"copy-protos": "node ./copy-protos"
},
"dependencies": {
Expand Down
15 changes: 15 additions & 0 deletions packages/grpc-js/src/duration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,18 @@ export function parseDuration(value: string): Duration | null {
nanos: match[2] ? Number.parseInt(match[2].padEnd(9, '0'), 10) : 0
};
}

export function durationToString(duration: Duration): string {
if (duration.nanos === 0) {
return `${duration.seconds}s`;
}
let scaleFactor: number;
if (duration.nanos % 1_000_000 === 0) {
scaleFactor = 1_000_000;
} else if (duration.nanos % 1_000 === 0) {
scaleFactor = 1_000;
} else {
scaleFactor = 1;
}
return `${duration.seconds}.${duration.nanos/scaleFactor}s`;
}
2 changes: 2 additions & 0 deletions packages/grpc-js/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ import * as resolver_ip from './resolver-ip';
import * as load_balancer_pick_first from './load-balancer-pick-first';
import * as load_balancer_round_robin from './load-balancer-round-robin';
import * as load_balancer_outlier_detection from './load-balancer-outlier-detection';
import * as load_balancer_weighted_round_robin from './load-balancer-weighted-round-robin';
import * as channelz from './channelz';
import { Deadline } from './deadline';

Expand All @@ -306,5 +307,6 @@ import { Deadline } from './deadline';
load_balancer_pick_first.setup();
load_balancer_round_robin.setup();
load_balancer_outlier_detection.setup();
load_balancer_weighted_round_robin.setup();
channelz.setup();
})();
5 changes: 5 additions & 0 deletions packages/grpc-js/src/load-balancer-pick-first.ts
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,11 @@ export class PickFirstLoadBalancer implements LoadBalancer {
destroy() {
this.resetSubchannelList();
this.removeCurrentPick();
this.metricsCall?.cancel();
this.metricsCall = null;
this.orcaClient?.close();
this.orcaClient = null;
this.metricsBackoffTimer.stop();
}

getTypeName(): string {
Expand Down
Loading
Loading