@@ -316,25 +316,41 @@ var ProcLogic = function() {
316316 funcOuts , emul ,
317317 proc . engine . eventServer ,
318318 proc . engine . config ,
319- function ( err , outs , options ) {
319+ function ( err , ins , outs , options ) { // 'ins' is returned only for the purpose of persistence
320320 //onsole.log("FUNC INVOKED");
321321 //onsole.log("INS: ", JSON.stringify(proc.sigValues, null, 2));
322322 //onsole.log("OUTS: ", outs);
323- var outsArray = [ ] ;
323+
324+ // convert ins and outs object-arrays to arrays for the purpose of persistence
325+ var outsArray = [ ] , insArray = [ ] ;
324326 if ( outs == null ) {
325327 outsArray = null ;
326328 } else {
327- outs . forEach ( function ( out ) {
329+ outs . forEach ( function ( out , i ) {
328330 outsArray . push ( out ) ;
331+ // FIXME: the code below is repeated below in "postInvoke"
332+ // --> TODO: make a function for adding metadata to a signal
333+ outsArray [ i ] [ "_id" ] = + funcOuts [ i ] ;
334+ outsArray [ i ] [ "source" ] = + proc . procId ;
335+ outsArray [ i ] [ "firingId" ] = + proc . firingId ;
336+ } ) ;
337+ }
338+ if ( ins == null ) {
339+ insArray = null ;
340+ } else {
341+ ins . forEach ( function ( input ) {
342+ insArray . push ( input ) ;
329343 } ) ;
330344 }
331345
346+
332347 // persist outputs (originally persistence was disabled DURING recovery,
333348 // but it's probably wrong: currently even when recovering from a previous log,
334- // workflow execution is persisted normally to a new log
349+ // workflow execution is persisted normally to a new log)
335350 //if (!options || !options.recovered) {
336351 proc . engine . eventServer . emit ( "persist" ,
337- [ "fired" , proc . appId , proc . procId , proc . firingId , outsArray ] ) ;
352+ // FIXME: insArray only added for testing "pregel" algorithm
353+ [ "fired" , proc . appId , proc . procId , proc . firingId , outsArray , insArray ] ) ;
338354 //}
339355 err ? cb ( err ) : cb ( null , outs , asyncInvocation , funcIns , funcOuts ) ;
340356 }
0 commit comments