-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtask.js
33 lines (30 loc) · 965 Bytes
/
task.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
only needed to sinulate work / delay
const timer = (ms) => new Promise((res) => setTimeout(res, ms));
function randomIntFromInterval(min, max) { // min and max included
return Math.floor(Math.random() * (max - min + 1) + min);
}
*/
// Requre here libs you passed from master as dependencies
// if needed here.
// const { Big } = require('big.js');
class Task {
constructor() {
this.data = null;
}
/**
* Description: This method is the job procces. Receives job data (job)
* Must return job results (Object) , to delivered in master.
* @param {Object} job data from Master about job {id: Number , data: String (needs JSON.parse)}
* @returns {Object} result
*/
async run(job) {
const data = JSON.parse(job.data);
this.data = data;
// eslint-disable-next-line no-console
console.dir(job);
// code to run in workers
return {};
}
}
module.exports = Task;