noflo / noflo-runtime-msgflo

NoFlo runtime for AMQP/MQTT
10 stars 8 forks source link

How to implement embed msgFlo in my nodejs code? #230

Open mohandass-pat opened 4 years ago

mohandass-pat commented 4 years ago

I want to dynamically pass the graph in node.js. How to achieve that like in noFlo (https://noflojs.org/documentation/embedding/)?

jonnor commented 4 years ago

Am I understanding you correctly?

  1. You have a dynamically created NoFlo graph
  2. and you want to execute as a MsgFlo participant
  3. and the graph not depend on the input message from AMQP/MQTT
  4. and you want to do this programatically without a subprocess?

If so, then look at the internal code. https://github.com/noflo/noflo-runtime-msgflo/blob/master/src/mount.coffee#L266

You need to create a Mounter and pass in { graph: 'name-of-graph' }. This graphname is looked up by the NoFlo loader. So you should be able to register your new graph with the loader. Or your overload the loader .load() method to instatiante the graph yourself by passing in also { loader: ... graph: ... }

Note that this is not public API, and may change in newer versions of this library.

mohandass-pat commented 4 years ago

Thanks for the reply. I don't want to execute graph as a MsgFlo participant. I will have different components like 2 components in javascript, 2 components in python. The graph will use these components. The graph will be dynamically generated. But I want to execute this graph in msgFlo instead of noFo from my nodejs server. Is it possible? I dont want to use my graph as a participant. I want to execute my graph in msgFlo from code, without using terminal.