|
15 | 15 | *
|
16 | 16 | */
|
17 | 17 |
|
18 |
| -import { credentials, loadPackageDefinition, ServiceError } from "@grpc/grpc-js"; |
| 18 | +import { ChannelOptions, credentials, loadPackageDefinition, ServiceError } from "@grpc/grpc-js"; |
19 | 19 | import { loadSync } from "@grpc/proto-loader";
|
20 | 20 | import { ProtoGrpcType } from "./generated/echo";
|
21 | 21 | import { EchoTestServiceClient } from "./generated/grpc/testing/EchoTestService";
|
@@ -44,14 +44,14 @@ export class XdsTestClient {
|
44 | 44 | private client: EchoTestServiceClient;
|
45 | 45 | private callInterval: NodeJS.Timer;
|
46 | 46 |
|
47 |
| - constructor(target: string, bootstrapInfo: string) { |
48 |
| - this.client = new loadedProtos.grpc.testing.EchoTestService(target, credentials.createInsecure(), {[BOOTSTRAP_CONFIG_KEY]: bootstrapInfo}); |
| 47 | + constructor(target: string, bootstrapInfo: string, options?: ChannelOptions) { |
| 48 | + this.client = new loadedProtos.grpc.testing.EchoTestService(target, credentials.createInsecure(), {...options, [BOOTSTRAP_CONFIG_KEY]: bootstrapInfo}); |
49 | 49 | this.callInterval = setInterval(() => {}, 0);
|
50 | 50 | clearInterval(this.callInterval);
|
51 | 51 | }
|
52 | 52 |
|
53 |
| - static createFromServer(targetName: string, xdsServer: XdsServer) { |
54 |
| - return new XdsTestClient(`xds:///${targetName}`, xdsServer.getBootstrapInfoString()); |
| 53 | + static createFromServer(targetName: string, xdsServer: XdsServer, options?: ChannelOptions) { |
| 54 | + return new XdsTestClient(`xds:///${targetName}`, xdsServer.getBootstrapInfoString(), options); |
55 | 55 | }
|
56 | 56 |
|
57 | 57 | startCalls(interval: number) {
|
@@ -98,4 +98,8 @@ export class XdsTestClient {
|
98 | 98 | }
|
99 | 99 | sendInner(count, callback);
|
100 | 100 | }
|
| 101 | + |
| 102 | + getConnectivityState() { |
| 103 | + return this.client.getChannel().getConnectivityState(false); |
| 104 | + } |
101 | 105 | }
|
0 commit comments