Skip to content

Commit 619d6a5

Browse files
committed
Added global identifier "hfid". All IDs (hfId, appId, procId, firingId) are passed to the activity function (in parameter 'config').
1 parent ad5a126 commit 619d6a5

File tree

5 files changed

+37
-8
lines changed

5 files changed

+37
-8
lines changed

bin/hflow

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,11 @@ function hflow_run() {
7373

7474
var createWf = function(cb) {
7575
rcl.select(dbId, function(err, rep) {
76-
rcl.flushdb(function(err, rep) {
76+
//rcl.flushdb(function(err, rep) { // flushing db here deletes the global 'hfid' entry (created earlier)
7777
wflib.createInstanceFromFile(wffile, '', function(err, id) {
7878
cb(err, id);
7979
});
80-
});
80+
//});
8181
});
8282
}
8383

engine2/process.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,9 +306,10 @@ var ProcLogic = function() {
306306
}
307307
}
308308

309-
proc.wflib.invokeTaskFunction2(
309+
proc.wflib.invokeProcFunction(
310310
proc.appId,
311311
proc.procId,
312+
proc.firingId,
312313
funcIns,
313314
proc.sigValues,
314315
funcOuts, emul,

functions/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ function print2(ins, outs, config, cb) {
2626
console.log(input.data);
2727
}
2828
});
29+
console.log("CONFIG");
30+
console.log(config);
2931
cb(null, outs);
3032
}
3133

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
},
1111
"dependencies": {
1212
"express": "3.x",
13-
"consolidate": "0.9.1",
13+
"consolidate": "0.10.x",
1414
"cradle": "0.6.6",
1515
"ejs": "0.8.4",
1616
"eyes": "0.1.8",

wflib/index.js

Lines changed: 30 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,18 @@ var fs = require('fs'),
1111
Q = require('q'),
1212
pathTool = require('path'),
1313
//toobusy = require('toobusy'),
14+
uuid = require('uuid'),
1415
rcl;
1516

17+
1618
// for profiling
1719
var fetchInputsTime = 0;
1820
var sendSignalTime = 0;
1921

22+
23+
var global_hfid = 0; // global UUID of this HF engine instance (used for logging)
24+
var globalInfo = {}; // object holding global information for a given HF engine instance
25+
2026
function p0() {
2127
return (new Date()).getTime();
2228
}
@@ -33,7 +39,19 @@ exports.init = function(redisClient) {
3339
// optional passing of client could be possible);
3440
if (redisClient) {
3541
rcl = redisClient;
42+
if (global_hfid == 0) {
43+
global_hfid = uuid.v1();
44+
45+
// this object holds global information about this HF engine instance
46+
// written to redis as a hash map with key "globalinfo:<uuid>"
47+
// TODO: add more attributes
48+
globalInfo.hf_version = "???";
49+
50+
rcl.hmset("hflow:"+global_hfid, globalInfo, function(err, ret) { });
51+
}
3652
}
53+
54+
console.log("hfid:", global_hfid);
3755
/*rcl.on("error", function (err) {
3856
console.log("redis error: " + err);
3957
});*/
@@ -1336,7 +1354,7 @@ function public_getRemoteDataSinks(wfId, dataId, cb) {
13361354
* @insValues - array of input signal values as returned by fetchInputs
13371355
* @appConfig - configuration specific for this workflow instance (the engine.config object), e.g. working directory
13381356
*/
1339-
function public_invokeTaskFunction2(wfId, taskId, insIds_, insValues, outsIds_, emulate, eventServer, appConfig, cb) {
1357+
function public_invokeProcFunction(wfId, procId, firingId, insIds_, insValues, outsIds_, emulate, eventServer, appConfig, cb) {
13401358
function isArray(what) {
13411359
return Object.prototype.toString.call(what) === '[object Array]';
13421360
}
@@ -1377,7 +1395,7 @@ function public_invokeTaskFunction2(wfId, taskId, insIds_, insValues, outsIds_,
13771395

13781396
//onsole.log("FUNC INS", ins);
13791397

1380-
public_getTaskInfo(wfId, taskId, function(err, taskInfo) {
1398+
public_getTaskInfo(wfId, procId, function(err, taskInfo) {
13811399
if (err) return cb(err);
13821400

13831401
var asyncTasks = [];
@@ -1474,6 +1492,12 @@ function public_invokeTaskFunction2(wfId, taskId, insIds_, insValues, outsIds_,
14741492
conf['eventServer'] = eventServer;
14751493
}
14761494

1495+
// Pass identifiers to the function
1496+
conf.hfId = global_hfid;
1497+
conf.appId = wfId;
1498+
conf.procId = procId;
1499+
conf.firingId = firingId;
1500+
14771501
f(ins, outs, conf, function(err, outs, options) {
14781502
//if (outs) { onsole.log("VALUE="+outs[0].value); } // DEBUG
14791503
cb(null, outs, options);
@@ -1930,7 +1954,7 @@ return {
19301954
getRemoteDataSinks: public_getRemoteDataSinks,
19311955
getWfMap: public_getWfMap,
19321956
getTaskMap: public_getTaskMap,
1933-
invokeTaskFunction2: public_invokeTaskFunction2,
1957+
invokeProcFunction: public_invokeProcFunction,
19341958
//sendSignal: public_sendSignal,
19351959
sendSignal: sendSignalLua,
19361960
getSignalInfo: getSignalInfo,
@@ -1941,7 +1965,9 @@ return {
19411965
sendSignalLua: sendSignalLua,
19421966
getSigByName: getSigByName,
19431967
getSigRemoteSinks: getSigRemoteSinks,
1944-
setSigRemoteSinks: setSigRemoteSinks
1968+
setSigRemoteSinks: setSigRemoteSinks,
1969+
1970+
hfid: global_hfid
19451971
};
19461972

19471973
};

0 commit comments

Comments
 (0)