cleanup, job property storage
This commit is contained in:
@@ -13,7 +13,7 @@ export default class Elastique extends events.EventEmitter {
|
|||||||
interval: '1w',
|
interval: '1w',
|
||||||
timeout: 10000,
|
timeout: 10000,
|
||||||
}, omit(options, [ 'client' ]));
|
}, omit(options, [ 'client' ]));
|
||||||
this.client = createClient(options.client);
|
this.client = createClient(options.client || {});
|
||||||
}
|
}
|
||||||
|
|
||||||
add(type, payload, opts = {}) {
|
add(type, payload, opts = {}) {
|
||||||
@@ -21,7 +21,7 @@ export default class Elastique extends events.EventEmitter {
|
|||||||
timeout: this.settings.timeout
|
timeout: this.settings.timeout
|
||||||
}, opts);
|
}, opts);
|
||||||
|
|
||||||
var job = new Job(this, type, payload, options);
|
const job = new Job(this, type, payload, options);
|
||||||
return job;
|
return job;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
src/job.js
18
src/job.js
@@ -8,12 +8,24 @@ export default class Job extends events.EventEmitter {
|
|||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
queue.client.index({
|
this.queue = queue;
|
||||||
index: queue.index,
|
this.type = type;
|
||||||
type: type,
|
this.payload = payload;
|
||||||
|
this.timeout = options.timeout || 10000;
|
||||||
|
|
||||||
|
this.ready = this.queue.client.index({
|
||||||
|
index: this.queue.index,
|
||||||
|
type: this.type,
|
||||||
body: Object.assign({}, options, {
|
body: Object.assign({}, options, {
|
||||||
payload: payload
|
payload: payload
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
.then((doc) => {
|
||||||
|
this.document = {
|
||||||
|
id: doc._id,
|
||||||
|
type: doc._type,
|
||||||
|
version: doc._version,
|
||||||
|
};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user