add new events
one for when the search is completed, and one for when the job poller is ready
This commit is contained in:
@@ -5,6 +5,8 @@ export default {
|
|||||||
EVENT_JOB_CREATE_ERROR: 'job:creation error',
|
EVENT_JOB_CREATE_ERROR: 'job:creation error',
|
||||||
EVENT_WORKER_COMPLETE: 'worker:job complete',
|
EVENT_WORKER_COMPLETE: 'worker:job complete',
|
||||||
EVENT_WORKER_JOB_CLAIM_ERROR: 'worker:claim job error',
|
EVENT_WORKER_JOB_CLAIM_ERROR: 'worker:claim job error',
|
||||||
|
EVENT_WORKER_JOB_POLLING_READY: 'worker:job poller ready',
|
||||||
|
EVENT_WORKER_JOB_SEARCH_COMPLETE: 'worker:pending jobs returned',
|
||||||
EVENT_WORKER_JOB_SEARCH_ERROR: 'worker:pending jobs error',
|
EVENT_WORKER_JOB_SEARCH_ERROR: 'worker:pending jobs error',
|
||||||
EVENT_WORKER_JOB_UPDATE_ERROR: 'worker:update job error',
|
EVENT_WORKER_JOB_UPDATE_ERROR: 'worker:update job error',
|
||||||
EVENT_WORKER_JOB_FAIL: 'worker:job failed',
|
EVENT_WORKER_JOB_FAIL: 'worker:job failed',
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ export default class Worker extends events.EventEmitter {
|
|||||||
} , this.checkInterval);
|
} , this.checkInterval);
|
||||||
|
|
||||||
this._poller.running = true;
|
this._poller.running = true;
|
||||||
|
this.emit(constants.EVENT_WORKER_JOB_POLLING_READY);
|
||||||
}
|
}
|
||||||
|
|
||||||
_stopJobPolling() {
|
_stopJobPolling() {
|
||||||
@@ -349,7 +350,10 @@ export default class Worker extends events.EventEmitter {
|
|||||||
})
|
})
|
||||||
.then((results) => {
|
.then((results) => {
|
||||||
const jobs = results.hits.hits;
|
const jobs = results.hits.hits;
|
||||||
|
|
||||||
this.debug(`${jobs.length} outstanding jobs returned`);
|
this.debug(`${jobs.length} outstanding jobs returned`);
|
||||||
|
this.emit(constants.EVENT_WORKER_JOB_SEARCH_COMPLETE, jobs);
|
||||||
|
|
||||||
return jobs;
|
return jobs;
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user