collect indexSettings on queue creation, pass to job and use at index creation
This commit is contained in:
@@ -45,7 +45,8 @@ export default class Esqueue extends events.EventEmitter {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const options = Object.assign(defaults, opts, {
|
const options = Object.assign(defaults, opts, {
|
||||||
doctype: this.settings.doctype
|
doctype: this.settings.doctype,
|
||||||
|
indexSettings: this.settings.indexSettings,
|
||||||
});
|
});
|
||||||
|
|
||||||
return new Job(this.client, index, type, payload, options);
|
return new Job(this.client, index, type, payload, options);
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ export default class Job extends events.EventEmitter {
|
|||||||
this.maxAttempts = options.max_attempts || 3;
|
this.maxAttempts = options.max_attempts || 3;
|
||||||
this.priority = Math.max(Math.min(options.priority || 10, 20), -20);
|
this.priority = Math.max(Math.min(options.priority || 10, 20), -20);
|
||||||
this.doctype = options.doctype || contstants.DEFAULT_SETTING_DOCTYPE;
|
this.doctype = options.doctype || contstants.DEFAULT_SETTING_DOCTYPE;
|
||||||
|
this.indexSettings = options.indexSettings || {};
|
||||||
|
|
||||||
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
this.debug = (...msg) => debug(...msg, `id: ${this.id}`);
|
||||||
|
|
||||||
@@ -48,7 +49,7 @@ export default class Job extends events.EventEmitter {
|
|||||||
|
|
||||||
if (options.headers) indexParams.headers = options.headers;
|
if (options.headers) indexParams.headers = options.headers;
|
||||||
|
|
||||||
this.ready = createIndex(this.client, this.index, this.doctype)
|
this.ready = createIndex(this.client, this.index, this.doctype, this.indexSettings)
|
||||||
.then(() => this.client.index(indexParams))
|
.then(() => this.client.index(indexParams))
|
||||||
.then((doc) => {
|
.then((doc) => {
|
||||||
this.document = {
|
this.document = {
|
||||||
|
|||||||
Reference in New Issue
Block a user