From c79da26f2d46de661a1fa153e15b11e23b010eec Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 25 Apr 2016 13:43:48 -0700 Subject: [PATCH] fix bug on new job - return the promise --- src/job.js | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/job.js b/src/job.js index 20db787..efe2203 100644 --- a/src/job.js +++ b/src/job.js @@ -13,27 +13,26 @@ export default class Job extends events.EventEmitter { super(); - const timeout = options.timeout || 10000; - const maxAttempts = options.max_attempts || 3; - const priority = Math.max(Math.min(options.priority || 10, 20), -20); - this.client = client; this.index = index; this.type = type; this.payload = payload; + this.timeout = options.timeout || 10000; + this.maxAttempts = options.max_attempts || 3; + this.priority = Math.max(Math.min(options.priority || 10, 20), -20); this.ready = createIndex(client, index) .then(() => { - this.client.index({ + return this.client.index({ index: this.index, type: this.type, body: { payload: this.payload, - priority: priority, - timeout: timeout, + priority: this.priority, + timeout: this.timeout, created_at: new Date(), attempts: 0, - max_attempts: maxAttempts, + max_attempts: this.maxAttempts, status: JOB_STATUS_PENDING, } })