UNPKG

@camunda8/sdk

Version:

[![NPM](https://nodei.co/npm/@camunda8/sdk.png)](https://www.npmjs.com/package/@camunda8/sdk)

44 lines 1.73 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ConnectionFactory = exports.ConnectionCharacteristics = void 0; const GrpcMiddleware_1 = require("./GrpcMiddleware"); const StatefulLogInterceptor_1 = require("./StatefulLogInterceptor"); /** * @TODO we need to override this via the constructor */ exports.ConnectionCharacteristics = { CAMUNDA_CLOUD: { _tag: 'CAMUNDA_CLOUD', startupTime: parseInt(process.env.ZEEBE_INITIAL_CONNECTION_TOLERANCE || '6000', 10), }, VANILLA: { _tag: 'VANILLA', startupTime: parseInt(process.env.ZEEBE_INITIAL_CONNECTION_TOLERANCE || '0', 10), }, }; class ConnectionFactory { static getGrpcClient({ grpcConfig, logConfig, }) { const characteristics = ConnectionFactory.getCharacteristics(grpcConfig.host); const log = new StatefulLogInterceptor_1.StatefulLogInterceptor({ characteristics, logConfig }); const grpcMiddleware = new GrpcMiddleware_1.GrpcMiddleware({ characteristics, config: grpcConfig, log, }); const grpcClient = grpcMiddleware.getGrpcClient(); const _close = grpcClient.close.bind(grpcClient); grpcClient.close = async () => { log.close(); _close(); return grpcMiddleware.close(); }; return { grpcClient, log }; } static getCharacteristics(host) { const isCamundaCloud = host.includes('zeebe.camunda.io'); const profile = isCamundaCloud ? 'CAMUNDA_CLOUD' : 'VANILLA'; return exports.ConnectionCharacteristics[profile]; } } exports.ConnectionFactory = ConnectionFactory; //# sourceMappingURL=ConnectionFactory.js.map