Set a deadline on outgoing requests in the xds interop client

This commit is contained in:
Michael Lumish 2020-08-28 12:50:53 -07:00
parent 5827b3e01d
commit 36db24e39f
1 changed files with 5 additions and 1 deletions

View File

@ -37,6 +37,8 @@ const packageDefinition = protoLoader.loadSync('grpc/testing/test.proto', {
const loadedProto = grpc.loadPackageDefinition(packageDefinition) as unknown as ProtoGrpcType;
const REQUEST_TIMEOUT_SEC = 20;
interface CallEndNotifier {
onCallSucceeded(peerName: string): void;
onCallFailed(message: string): void;
@ -151,7 +153,9 @@ function sendConstantQps(client: TestServiceClient, qps: number, failOnFailedRpc
let hostname: string | null = null;
let completed: 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 (failOnFailedRpcs && anyCallSucceeded) {
console.error('A call failed after a call succeeded');