parent
6d7eb50429
commit
a31424e3e7
2 changed files with 28 additions and 36 deletions
@ -1,30 +1,15 @@ |
||||
const { |
||||
send, |
||||
} = require('./worker/node'); |
||||
const log = require('./utils/log'); |
||||
|
||||
let jobCounter = 0; |
||||
let jobCounter = 1; |
||||
|
||||
module.exports = ( |
||||
action, |
||||
payload, |
||||
) => { |
||||
jobCounter += 1; |
||||
const id = `Job-${jobCounter}-${Math.random().toString(16).slice(3, 8)}`; |
||||
|
||||
const start = async (w) => { |
||||
log(`[${w.id}]: Start ${id}, action=${action}`); |
||||
send(w.worker, { |
||||
workerId: w.id, |
||||
jobId: id, |
||||
action, |
||||
payload, |
||||
}); |
||||
}; |
||||
jobCounter += 1; |
||||
|
||||
return { |
||||
id, |
||||
action, |
||||
start, |
||||
payload, |
||||
}; |
||||
}; |
||||
|
Loading…
Reference in new issue