From 40d67829c86bba78d328c2be1de313d7141db078 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 11 Jul 2016 11:28:40 -0700 Subject: [PATCH] pass the entire queue to the Job instance --- src/index.js | 2 +- src/job.js | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/index.js b/src/index.js index 85826e1..074fe85 100644 --- a/src/index.js +++ b/src/index.js @@ -49,7 +49,7 @@ export default class Esqueue extends events.EventEmitter { indexSettings: this.settings.indexSettings, }); - return new Job(this.client, index, type, payload, options); + return new Job(this, index, type, payload, options); } registerWorker(type, workerFn, opts) { diff --git a/src/job.js b/src/job.js index ba33178..6b82e55 100644 --- a/src/job.js +++ b/src/job.js @@ -9,13 +9,14 @@ const debug = logger('esqueue:job'); const puid = new Puid(); export default class Job extends events.EventEmitter { - constructor(client, index, type, payload, options = {}) { + constructor(queue, index, type, payload, options = {}) { if (typeof type !== 'string') throw new Error('Type must be a string'); if (!isPlainObject(payload)) throw new Error('Payload must be a plain object'); super(); - this.client = options.client || client; + this.queue = queue; + this.client = options.client || this.queue.client; this.id = puid.generate(); this.index = index; this.jobtype = type;