From 32fb6a92f56b201361e555b2af41c6b2c63ccda1 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 23 May 2017 18:04:01 -0700 Subject: [PATCH] better fix for the worker doctype use the queue's doctype if one is not provided. also adds the option to the readme --- readme.md | 1 + src/index.js | 5 +---- src/worker.js | 2 +- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/readme.md b/readme.md index 662389b..3462bcf 100644 --- a/readme.md +++ b/readme.md @@ -114,6 +114,7 @@ Option | Default | Description interval | `1500` | Time, in `ms` to poll for new jobs in the queue. size | `10` | Number of records to return when polling for new jobs. Higher values may result in less Elasticsearch requests, but may also take longer to execute. A bit of tuning based on the number of workers you have my be required here. client | | Alternative elasticsearch client instance, if you need to use one other than what the queue was created with. +doctype | `queue.doctype` | The doctype to use when polling for new jobs. You probably don't want to change this. The worker's `output` can either be the raw output from the job, or on object that specifies the output's content type. diff --git a/src/index.js b/src/index.js index 83400d9..a9c17af 100644 --- a/src/index.js +++ b/src/index.js @@ -54,10 +54,7 @@ export default class Esqueue extends events.EventEmitter { } registerWorker(type, workerFn, opts) { - const options = Object.assign({ - doctype: this.settings.doctype, - }, opts); - const worker = new Worker(this, type, workerFn, options); + const worker = new Worker(this, type, workerFn, opts); this._workers.push(worker); return worker; } diff --git a/src/worker.js b/src/worker.js index b353ed1..e4cb865 100644 --- a/src/worker.js +++ b/src/worker.js @@ -30,7 +30,7 @@ export default class Worker extends events.EventEmitter { this.workerFn = workerFn; this.checkInterval = opts.interval || 1500; this.checkSize = opts.size || 10; - this.doctype = opts.doctype || constants.DEFAULT_SETTING_DOCTYPE; + this.doctype = opts.doctype || this.queue.doctype || constants.DEFAULT_SETTING_DOCTYPE; this.debug = (...msg) => debug(...msg, `id: ${this.id}`);