minor syntax change
make running more clearly a private state variable
This commit is contained in:
@@ -31,17 +31,17 @@ export default class Job extends events.EventEmitter {
|
|||||||
this.checkInterval = opts.interval || 1500;
|
this.checkInterval = opts.interval || 1500;
|
||||||
this.checkSize = opts.size || 10;
|
this.checkSize = opts.size || 10;
|
||||||
this.doctype = opts.doctype || constants.DEFAULT_SETTING_DOCTYPE;
|
this.doctype = opts.doctype || constants.DEFAULT_SETTING_DOCTYPE;
|
||||||
this.running = true;
|
|
||||||
|
|
||||||
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
||||||
|
|
||||||
this._checker = false;
|
this._checker = false;
|
||||||
|
this._running = true;
|
||||||
this.debug(`Created worker for job type ${this.jobtype}`);
|
this.debug(`Created worker for job type ${this.jobtype}`);
|
||||||
this._startJobPolling();
|
this._startJobPolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
destroy() {
|
||||||
this.running = false;
|
this._running = false;
|
||||||
clearInterval(this._checker);
|
clearInterval(this._checker);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -239,9 +239,10 @@ export default class Job extends events.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_startJobPolling() {
|
_startJobPolling() {
|
||||||
if (!this.running) {
|
if (!this._running) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this._checker = setInterval(() => {
|
this._checker = setInterval(() => {
|
||||||
this._getPendingJobs()
|
this._getPendingJobs()
|
||||||
.then((jobs) => this._claimPendingJobs(jobs));
|
.then((jobs) => this._claimPendingJobs(jobs));
|
||||||
|
|||||||
Reference in New Issue
Block a user