add a worker module

This commit is contained in:
2016-04-18 16:39:35 -07:00
parent 4416a5508d
commit 1b5f2af004
3 changed files with 23 additions and 1 deletions

15
src/worker.js Normal file
View File

@@ -0,0 +1,15 @@
import events from 'events';
import Puid from 'puid';
export default class Job extends events.EventEmitter {
constructor(queue, type, workerFn) {
if (typeof type !== 'string') throw new Error('Type must be a string');
if (typeof workerFn !== 'function') throw new Error('Worker must be a function');
super();
const puid = new Puid();
this.id = puid.generate();
// TODO: check for existing jobs to process
}
}