fix bug on new job - return the promise
This commit is contained in:
15
src/job.js
15
src/job.js
@@ -13,27 +13,26 @@ export default class Job extends events.EventEmitter {
|
|||||||
|
|
||||||
super();
|
super();
|
||||||
|
|
||||||
const timeout = options.timeout || 10000;
|
|
||||||
const maxAttempts = options.max_attempts || 3;
|
|
||||||
const priority = Math.max(Math.min(options.priority || 10, 20), -20);
|
|
||||||
|
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.payload = payload;
|
this.payload = payload;
|
||||||
|
this.timeout = options.timeout || 10000;
|
||||||
|
this.maxAttempts = options.max_attempts || 3;
|
||||||
|
this.priority = Math.max(Math.min(options.priority || 10, 20), -20);
|
||||||
|
|
||||||
this.ready = createIndex(client, index)
|
this.ready = createIndex(client, index)
|
||||||
.then(() => {
|
.then(() => {
|
||||||
this.client.index({
|
return this.client.index({
|
||||||
index: this.index,
|
index: this.index,
|
||||||
type: this.type,
|
type: this.type,
|
||||||
body: {
|
body: {
|
||||||
payload: this.payload,
|
payload: this.payload,
|
||||||
priority: priority,
|
priority: this.priority,
|
||||||
timeout: timeout,
|
timeout: this.timeout,
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
attempts: 0,
|
attempts: 0,
|
||||||
max_attempts: maxAttempts,
|
max_attempts: this.maxAttempts,
|
||||||
status: JOB_STATUS_PENDING,
|
status: JOB_STATUS_PENDING,
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user