zeebe-node
Version:
The Node.js client library for the Zeebe Workflow Automation Engine.
43 lines • 2.32 kB
JavaScript
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ZBBatchWorker = void 0;
const chalk_1 = __importDefault(require("chalk"));
const JobBatcher_1 = require("../lib/JobBatcher");
const ZBWorkerBase_1 = require("../lib/ZBWorkerBase");
class ZBBatchWorker extends ZBWorkerBase_1.ZBWorkerBase {
constructor(config) {
super(config);
this.jobBatchMaxTime = config.options.jobBatchMaxTime;
if (this.timeout < this.jobBatchMaxTime) {
const jobBatchMaxTimeout = this.jobBatchMaxTime;
this.log(`\n`);
this.log(chalk_1.default.redBright(`=================================`));
this.log(`${chalk_1.default.yellowBright('WARNING:')} The ${this.taskType} batch worker is ${chalk_1.default.yellowBright('MISCONFIGURED')}.`);
this.log(`Its settings can ${chalk_1.default.yellowBright('RESULT IN ITS JOBS TIMING OUT')}.`);
this.log(`The ${chalk_1.default.greenBright('jobBatchMaxTimeout')}: ${jobBatchMaxTimeout} is longer than the ${chalk_1.default.greenBright('timeout')}: ${this.timeout}.`);
this.log(`This can lead to jobs timing out and retried by the broker before this worker executes their batch.`);
this.log(chalk_1.default.redBright('This is probably not the behaviour you want. Read the docs, and reconsider your life choices.'));
this.log(chalk_1.default.yellowBright(`Recommended: Reconfigure the ZBBatchWorker to have a higher timeout than its jobBatchMaxTimeout setting.`));
this.log(chalk_1.default.redBright(`=================================`));
this.log(`\n`);
}
this.jobBuffer = new JobBatcher_1.JobBatcher({
batchSize: this.jobBatchMinSize,
handler: this.taskHandler,
timeout: this.jobBatchMaxTime,
worker: this,
});
}
async handleJobs(jobs) {
const batchedJobs = jobs.map((job) => ({
...job,
...this.makeCompleteHandlers(job),
}));
this.jobBuffer.batch(batchedJobs);
}
}
exports.ZBBatchWorker = ZBBatchWorker;
//# sourceMappingURL=ZBBatchWorker.js.map