UNPKG

@iredium/butterfly

Version:
42 lines (41 loc) 1.67 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var job_1 = require("../../jobs/job"); var SampleJob = /** @class */ (function (_super) { __extends(SampleJob, _super); function SampleJob() { var _this = _super !== null && _super.apply(this, arguments) || this; _this.name = 'iredium.jobs.sample-job'; _this.maxActiveJob = 3; return _this; } SampleJob.prototype.perform = function (job, done) { var currentProgress = 0; console.log('start job'); var totalTime = 100 * Math.floor(Math.random() * 60); var updateProgressInterval = setInterval(function () { currentProgress += 100; job.progress(currentProgress, totalTime); }, 1000); setTimeout(function () { console.log("Test job complete. Here is the message from the job: " + JSON.stringify(job.data)); clearInterval(updateProgressInterval); done(); }, totalTime); }; return SampleJob; }(job_1.Job)); exports.SampleJob = SampleJob;