-
Notifications
You must be signed in to change notification settings - Fork 1
/
servequeue.js
75 lines (61 loc) · 2.48 KB
/
servequeue.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/**
* Created by mox on 29/03/16.
*/
'use strict';
var FatusQueue = require('./fatus');
var json2html = require('node-json2html');
var async = require('async');
var util = require('util');
/**
* work in progress class for presentations purpose
*/
class ServeFatusQueue{
invoke(req,res){
let fatusQ = FatusQueue.instance;
let failQ = null;
let goodQ = null;
let workerW = fatusQ.workerPool;
let priorityW = fatusQ.priorityWorkerPool;
let failW = fatusQ.failWorkerPool;
let collW = fatusQ.collectorPool;
async.parallel([
function getAllGood(cb){
fatusQ.getAll(
function onGet(err,val){
goodQ = val;
cb(err,val);
});
},
function getAllFail(cb){
fatusQ.getAllFail(
function onGet(err,val){
failQ = val;
cb(err,val);
}
)
}
],
function onFinish(err,val){
if(!err){
var jtransform = {'tag':'li','html':'${messageId} - ${insertionTime}: <b> ${messageText.module}/${messageText.function} </b> - ${messageText.fail} '};
var wtrasform = {'tag':'li','html':'${name} - ${creation}: IT:[${iteration}] FIT:[${fetchIteration}] PROC:[${processingId}]'};
var htmlok = json2html.transform(goodQ,jtransform);
var htmlfail = json2html.transform(failQ,jtransform);
var htmlw = json2html.transform(workerW,wtrasform);
var failw = json2html.transform(failW,wtrasform);
var priow = json2html.transform(priorityW,wtrasform);
var colw = json2html.transform(collW,wtrasform);
var html = '<html><body><div>OK:' + htmlok + '</div><div>FAIL:' + htmlfail + '</div><div>WW:' + htmlw + '</div><div>FW:' + failw + '</div><div>PW:' + priow + '</div><div>CL:' + colw + '</div></body></html>';
//console.log(html);
res.send(html);
res.end();
}else{
res.statusCode = 500;
res.send(new Error(500));
res.end();
}
});
}
}
/** Exports */
module.exports = ServeFatusQueue;