netflix-conductor-utilities
Version:
Netflix conductor utilities
44 lines • 2.04 kB
JavaScript
;
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const utils_1 = require("./utils");
const config_1 = __importDefault(require("./config"));
const src_1 = require("../src");
const fakeTaskProcessingTime = 60000;
const worker = new src_1.ConductorWorker({
url: config_1.default.url,
// apiPath: config.apiPath, // base path
workerid: utils_1.DEMO_WORKER_ID,
maxConcurrent: 2,
// runningTaskOptions: {
// keepAliveTimer: {
// enable: true,
// }
// }
});
const taskType = config_1.default.taskType;
(() => __awaiter(void 0, void 0, void 0, function* () {
console.log('Work polling');
worker.start(taskType, (input, task) => __awaiter(void 0, void 0, void 0, function* () {
console.log(`deal with the task: ${JSON.stringify(task.options)}`);
yield task.sendLog('before 1');
yield task.sendLog('before 2');
yield (0, utils_1.delay)(fakeTaskProcessingTime);
yield task.sendLog('after 1');
yield task.sendLog('after 2');
console.log('Finish to deal with the task');
}), 2000);
console.log('Start workflow');
}))().then(console.log);
//# sourceMappingURL=example-worker.js.map