distiguish the doctype from the jobtype

update tests and mock elasticsearch client
This commit is contained in:
2016-05-12 12:20:49 -07:00
parent 3375335d24
commit 609e81fdef
4 changed files with 32 additions and 13 deletions

View File

@@ -1,7 +1,7 @@
import { defaultSettings } from './constants';
const schema = {
type: { type: 'string', index: 'not_analyzed' },
jobtype: { type: 'string', index: 'not_analyzed' },
payload: { type: 'object', enabled: false },
priority: { type: 'short' },
timeout: { type: 'long' },

View File

@@ -18,7 +18,7 @@ export default class Job extends events.EventEmitter {
this.client = client;
this.id = puid.generate();
this.index = index;
this.type = type;
this.jobtype = type;
this.payload = payload;
this.timeout = options.timeout || 10000;
this.maxAttempts = options.max_attempts || 3;
@@ -31,9 +31,10 @@ export default class Job extends events.EventEmitter {
.then(() => {
return this.client.index({
index: this.index,
type: this.type,
type: this.doctype,
id: this.id,
body: {
jobtype: this.jobtype,
payload: this.payload,
priority: this.priority,
timeout: this.timeout,
@@ -66,7 +67,7 @@ export default class Job extends events.EventEmitter {
.then(() => {
return this.client.get({
index: this.index,
type: this.type,
type: this.doctype,
id: this.id
});
})
@@ -84,7 +85,8 @@ export default class Job extends events.EventEmitter {
return Object.assign({
id: this.id,
index: this.index,
type: this.type,
type: this.doctype,
jobtype: this.jobtype,
payload: this.payload,
timeout: this.timeout,
max_attempts: this.maxAttempts,