better fix for the worker doctype
use the queue's doctype if one is not provided. also adds the option to the readme
This commit is contained in:
@@ -114,6 +114,7 @@ Option | Default | Description
|
|||||||
interval | `1500` | Time, in `ms` to poll for new jobs in the queue.
|
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.
|
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.
|
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.
|
The worker's `output` can either be the raw output from the job, or on object that specifies the output's content type.
|
||||||
|
|
||||||
|
|||||||
@@ -54,10 +54,7 @@ export default class Esqueue extends events.EventEmitter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
registerWorker(type, workerFn, opts) {
|
registerWorker(type, workerFn, opts) {
|
||||||
const options = Object.assign({
|
const worker = new Worker(this, type, workerFn, opts);
|
||||||
doctype: this.settings.doctype,
|
|
||||||
}, opts);
|
|
||||||
const worker = new Worker(this, type, workerFn, options);
|
|
||||||
this._workers.push(worker);
|
this._workers.push(worker);
|
||||||
return worker;
|
return worker;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export default class Worker extends events.EventEmitter {
|
|||||||
this.workerFn = workerFn;
|
this.workerFn = workerFn;
|
||||||
this.checkInterval = opts.interval || 1500;
|
this.checkInterval = opts.interval || 1500;
|
||||||
this.checkSize = opts.size || 10;
|
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}`);
|
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user