add job object, and tests

This commit is contained in:
2016-04-15 16:51:56 -07:00
parent 822019f12a
commit 9f495c7791
3 changed files with 108 additions and 1 deletions

19
src/job.js Normal file
View File

@@ -0,0 +1,19 @@
import events from 'events';
import { isPlainObject } from 'lodash';
export default class Job extends events.EventEmitter {
constructor(queue, type, payload, options = {}) {
if (typeof type !== 'string') throw new Error('Type must be a string');
if (!isPlainObject(payload)) throw new Error('Payload must be a plain object');
super();
queue.client.index({
index: queue.index,
type: type,
body: Object.assign({}, options, {
payload: payload
})
});
}
}