mirror of https://github.com/grpc/grpc-node.git
Set a deadline on outgoing requests in the xds interop client
This commit is contained in:
parent
5827b3e01d
commit
36db24e39f
|
@ -37,6 +37,8 @@ const packageDefinition = protoLoader.loadSync('grpc/testing/test.proto', {
|
||||||
|
|
||||||
const loadedProto = grpc.loadPackageDefinition(packageDefinition) as unknown as ProtoGrpcType;
|
const loadedProto = grpc.loadPackageDefinition(packageDefinition) as unknown as ProtoGrpcType;
|
||||||
|
|
||||||
|
const REQUEST_TIMEOUT_SEC = 20;
|
||||||
|
|
||||||
interface CallEndNotifier {
|
interface CallEndNotifier {
|
||||||
onCallSucceeded(peerName: string): void;
|
onCallSucceeded(peerName: string): void;
|
||||||
onCallFailed(message: string): void;
|
onCallFailed(message: string): void;
|
||||||
|
@ -151,7 +153,9 @@ function sendConstantQps(client: TestServiceClient, qps: number, failOnFailedRpc
|
||||||
let hostname: string | null = null;
|
let hostname: string | null = null;
|
||||||
let completed: boolean = false;
|
let completed: boolean = false;
|
||||||
let completedWithError: boolean = false;
|
let completedWithError: boolean = false;
|
||||||
const call = client.emptyCall({}, (error, value) => {
|
const deadline = new Date();
|
||||||
|
deadline.setSeconds(deadline.getSeconds() + REQUEST_TIMEOUT_SEC);
|
||||||
|
const call = client.emptyCall({}, {deadline}, (error, value) => {
|
||||||
if (error) {
|
if (error) {
|
||||||
if (failOnFailedRpcs && anyCallSucceeded) {
|
if (failOnFailedRpcs && anyCallSucceeded) {
|
||||||
console.error('A call failed after a call succeeded');
|
console.error('A call failed after a call succeeded');
|
||||||
|
|
Loading…
Reference in New Issue