From a4809e5e8db034f88f04136a6568251e9e41d380 Mon Sep 17 00:00:00 2001 From: Nicholas Molnar <65710+neekolas@users.noreply.github.com> Date: Thu, 2 May 2024 14:17:39 -0700 Subject: [PATCH] Move options out of function --- packages/grpc-api-client/src/GrpcApiClient.ts | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/packages/grpc-api-client/src/GrpcApiClient.ts b/packages/grpc-api-client/src/GrpcApiClient.ts index 586d782..51bc373 100644 --- a/packages/grpc-api-client/src/GrpcApiClient.ts +++ b/packages/grpc-api-client/src/GrpcApiClient.ts @@ -44,6 +44,13 @@ const API_URLS: { [k: string]: string } = { const SLEEP_TIME = 1000 const MAX_RETRIES = 4 +const clientOptions = { + "grpc.keepalive_timeout_ms": 1000 * 10, // 10 seconds + "grpc.keepalive_time_ms": 1000 * 30, // 30 seconds + "grpc.enable_retries": 1, + "grpc.keepalive_permit_without_calls": 0, +} as const + export default class GrpcApiClient implements ApiClient { grpcClient: MessageApiClient private authCache?: AuthCache @@ -55,16 +62,10 @@ export default class GrpcApiClient implements ApiClient { this.apiUrl = apiUrl this.appVersion = appVersion this.logger = pino({ name: "GrpcApiClient" }) - const grpcOptions = { - "grpc.keepalive_timeout_ms": 1000 * 10, // 10 seconds - "grpc.keepalive_time_ms": 1000 * 30, // 30 seconds - "grpc.enable_retries": 1, - "grpc.keepalive_permit_without_calls": 0, - } this.grpcClient = new MessageApiClient( new GrpcTransport({ host: apiUrl, - clientOptions: grpcOptions, + clientOptions, channelCredentials: isSecure ? credentials.createSsl() : credentials.createInsecure(),