Refactor to worker version

This commit is contained in:
Jerome Wu
2019-10-24 07:47:11 +08:00
parent 99adf5138c
commit 9e5d0c5cc6
42 changed files with 579 additions and 109 deletions

21
src/createJob.js Normal file
View File

@@ -0,0 +1,21 @@
const getId = require('./utils/getId');
let jobCounter = 0;
module.exports = ({
id: _id,
action,
payload = {},
}) => {
let id = _id;
if (typeof id === 'undefined') {
id = getId('Job', jobCounter);
jobCounter += 1;
}
return {
id,
action,
payload,
};
};