1 |
|
2 |
|
3 |
|
4 | 'use strict';
|
5 |
|
6 | const Base = require('../base/Base');
|
7 |
|
8 | module.exports = class Job extends Base {
|
9 |
|
10 | isCanceled () {
|
11 | return this._canceled;
|
12 | }
|
13 |
|
14 | async run () {
|
15 |
|
16 | }
|
17 |
|
18 | cancel () {
|
19 | this._canceled = true;
|
20 | }
|
21 |
|
22 | async execute () {
|
23 | if (this._started) {
|
24 | throw new Error('Job has already started');
|
25 | }
|
26 | this._started = true;
|
27 | await PromiseHelper.setImmediate();
|
28 | await this.run();
|
29 | }
|
30 |
|
31 | log () {
|
32 | this.task.log(...arguments);
|
33 | }
|
34 | };
|
35 |
|
36 | const PromiseHelper = require('../helper/PromiseHelper'); |
\ | No newline at end of file |