UNPKG

zeebe-node

Version:

The Node.js client library for the Zeebe Workflow Automation Engine.

40 lines 1.6 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"); 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 grpcClient = new GrpcMiddleware_1.GrpcMiddleware({ characteristics, config: grpcConfig, log, }).getGrpcClient(); const _close = grpcClient.close.bind(grpcClient); grpcClient.close = async () => { log.close(); _close(); return null; }; 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