add new events

one for when the search is completed, and one for when the job poller is ready
This commit is contained in:
2017-05-23 20:11:07 -07:00
parent 128905cdb4
commit 6bdf7163b6
2 changed files with 6 additions and 0 deletions

View File

@@ -5,6 +5,8 @@ export default {
EVENT_JOB_CREATE_ERROR: 'job:creation error',
EVENT_WORKER_COMPLETE: 'worker:job complete',
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_UPDATE_ERROR: 'worker:update job error',
EVENT_WORKER_JOB_FAIL: 'worker:job failed',

View File

@@ -270,6 +270,7 @@ export default class Worker extends events.EventEmitter {
} , this.checkInterval);
this._poller.running = true;
this.emit(constants.EVENT_WORKER_JOB_POLLING_READY);
}
_stopJobPolling() {
@@ -349,7 +350,10 @@ export default class Worker extends events.EventEmitter {
})
.then((results) => {
const jobs = results.hits.hits;
this.debug(`${jobs.length} outstanding jobs returned`);
this.emit(constants.EVENT_WORKER_JOB_SEARCH_COMPLETE, jobs);
return jobs;
})
.catch((err) => {