-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathStats.js
54 lines (37 loc) · 1 KB
/
Stats.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* create Worker ClassObject */
class Stats {
constructor(db, workers) { // Constructor
this.db = db;
this.workers = workers;
}
isWorkerOnline(workerId){
let worker = this.workers.getWorker(workerId);
if(worker.socket.isConnected == true){
return true;
}
return false;
}
connectedWorkers(isOnline){
let connected_workers = [];
let workers = this.workers.getAllWorkers();
for(const workerId in workers){
let worker = workers[workerId.toString()];
if(worker.socket.isConnected == isOnline){
connected_workers[workerId.toString()] = worker;
}
}
return connected_workers;
}
errorWorkers(){
let error_workers = [];
let workers = this.workers.getAllWorkers();
for(const workerId in workers){
let worker = workers[workerId.toString()];
if(worker.socket.isError == true){
error_workers[workerId.toString()] = worker;
}
}
return error_workers;
}
}
module.exports = Stats;