- Notifications
You must be signed in to change notification settings - Fork2
Node.js participant support for MsgFlo
License
msgflo/msgflo-nodejs
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
MsgFlo is a distributed, polyglot FBP (flow-based-programming)runtime. It integrates with other FBP tools like theFlowhub visual programming IDE.
This library makes it easy to create MsgFlo participants in JavaScript/CoffeScript on node.js.
Production
- Used atTheGrid for all workers using AMQP/RabbitMQ,including inimgflo-server
- Also used bynoflo-runtime-msgflo
- Experimental support for MQTT and direct transports
MIT, see./LICENSE
Add as an NPM dependency
npm install --save msgflo-nodejs
A simple participant (CoffeeScript)
msgflo = require 'msgflo-nodejs'RepeatParticipant = (client, role) -> definition = component: 'Repeat' icon: 'file-word-o' label: 'Repeats in data without changes' inports: [ id: 'in' type: 'any' ] outports: [ id: 'out' type: 'any' ] process = (inport, indata, callback) -> return callback 'out', null, indata return new msgflo.participant.Participant client, definition, process, roleclient = msgflo.transport.getClient 'amqp://localhost'worker = RepeatParticipant client, 'repeater'worker.start (err) -> throw err if err console.log 'Worker started'
If you expose the participant factory function (examples/Repeat.coffee)
module.exports = RepeatParticipant
Then you can use themsgflo-nodejs
exectutable to start participant
msgflo-nodejs --name repeater ./examples/Repeat.coffee
msgflo-nodejs uses thedebug NPM module.You can enable (all) logging using:
export DEBUG=msgflo*
msgflo-nodejs has a transport abstraction layer. So to support a new messaging system,implementClient
andMessageBroker
interfaces.
You can then pass the Client instance into aParticipant
.
Or you can register a new transport usingmsgflo.transport.register('mytransport', myTransportModule)
.Then you can get a Client instance usingmsgflo.transport.getClient('mytransport://somehost:666')
.This has the advantage of also working when specifying the broker URL usingmsgflo-nodejs --broker
orMSGFLO_BROKER=
environment variable.
About
Node.js participant support for MsgFlo