pass the entire queue to the Job instance
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user