push messages to parent process

Discussion created by alex.zwinge on Mar 15, 2016
Latest reply on Mar 15, 2016 by alex.zwinge

I am currently developing a process for our change management folks, in it, I am making heavy use of sub processes for just about everything; the main process controls only the flow while the sub processes is where the work actually gets done, so each 'task' and automated action takes place in it's own sub process. Basically, trying to make it very modular in design. I'm making liberal use of logEvent in the top parent process after each child process completes but, really with this design it makes a lot more sense for the logging to live in the child processes than the parent.


It seems fairly impossible or too difficult to call logEvent in the context of the parent from a child so I got the idea I could just create a logQueue on the parent process and have the children push their messages to it and then have a looping operator on the parent that shifts and logs messages. Sounds great, except the `Caller` variable seems to only be defined in the initialization portion of the child process. Okay I thought, maybe if I assign the var in the child it will be a reference to the to parent, nope, it 'passes' by value not reference, so the child ends up with it's own copy. A global dataset is a possible solution i think but keeping things to the smallest scope possible is always a better solution.


so the tl;dr is: how can i push to an array that exists in the parents dataset


here's code that exemplifies what I'm trying to do:


// in parent process

Process.logQueue = [ ];


// in any operator on the child process


// do this, 'my message'); // push does not exist on the C2oValueArray prototype but the type is still iterable, hence the call


// or this

Process.logQueue = Caller.logQueue; // in proc init, 'my message'); // in any operator, this would actually push to the parent process if it was a ref, not a copy