From d2e843f05b5e9e3d4276dba622e8569841fcee28 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Tue, 28 Jun 2016 18:29:56 -0700 Subject: [PATCH] collect indexSettings on queue creation, pass to job and use at index creation --- src/index.js | 3 ++- src/job.js | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/index.js b/src/index.js index e1e676a..c5e349d 100644 --- a/src/index.js +++ b/src/index.js @@ -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); diff --git a/src/job.js b/src/job.js index 37e1224..0aa5979 100644 --- a/src/job.js +++ b/src/job.js @@ -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 = {