Multi-threaded function node for NODE-RED
$ npm i node-red-contrib-mp-function
Or globally alongside Node-RED:
sudo npm i -g node-red-contrib-mp-function
You will need to restart Node-RED for it to pick-up the new nodes.
Changes in 1.1.1
fix Sometimes script is not catching configuration in non-persistent mode.
Changes in 1.1.0
new Added persistent option. When OFF new threads are created when new message arrives and are terminated when work is complete (thread limit and message caching also works). When ON, threads are waiting for messages as usual. new Command line for worker thread now contains name of the node. So you can kill it with fire, if anything happens.
Changes in 1.0.5
new Change from round-robin message distribution to load-balanced. When all threads are loaded incoming messages are queued. When thread calculation is finished, node will check inner message queue for new tasks. fix Fix vm context failure on creation of new script setup.
node-red-contrib-mp-function is based on original IBM function node. You need to see it basic usage at first. This node allows you to run your hardcore calculation code in separate process (or some of them) without freezing of node-red process and your other precious flows.
As you can import some external npm modules from node-red configuration? you can provide them into this node in 'Requires' field. The string must contain a name prefered for usage in your code and module name (or path to it) connected by an '<-' and joined by colon. For example:
The imported modules are accessible via context.global.yourmodulename for compatibility with original module
You can not use context, flow or global variables... yet. Write necessary info to the msg var before passing it into node. Event handlers on node variable also do not work. And probably wont.
But you can print messages with node.log, node.warn and node.error. And you can use statuses as well.