collect indexSettings on queue creation, pass to job and use at index creation

This commit is contained in:
2016-06-28 18:29:56 -07:00
parent 13a78d12cc
commit d2e843f05b
2 changed files with 4 additions and 2 deletions

View File

@@ -45,7 +45,8 @@ export default class Esqueue extends events.EventEmitter {
};
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);

View File

@@ -25,6 +25,7 @@ export default class Job extends events.EventEmitter {
this.maxAttempts = options.max_attempts || 3;
this.priority = Math.max(Math.min(options.priority || 10, 20), -20);
this.doctype = options.doctype || contstants.DEFAULT_SETTING_DOCTYPE;
this.indexSettings = options.indexSettings || {};
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;
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((doc) => {
this.document = {