0.11.1 • Published 7 years ago

msgflo-nodejs v0.11.1

Weekly downloads
2
License
MIT
Repository
github
Last release
7 years ago

msgflo-nodejs Build Status

MsgFlo is a distributed, polyglot FBP (flow-based-programming) runtime. It integrates with other FBP tools like the Flowhub visual programming IDE.

This library makes it easy to create MsgFlo participants in JavaScript/CoffeScript on node.js.

Status

Production

Licence

MIT, see ./LICENSE

Usage

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, role

client = 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 the msgflo-nodejs exectutable to start participant

msgflo-nodejs --name repeater ./examples/Repeat.coffee

Debugging

msgflo-nodejs uses the debug NPM module. You can enable (all) logging using:

export DEBUG=msgflo*

Supporting other transports

msgflo-nodejs has a transport abstraction layer. So to support a new messaging system, implement Client and MessageBroker interfaces.

You can then pass the Client instance into a Participant.

Or you can register a new transport using msgflo.transport.register('mytransport', myTransportModule). Then you can get a Client instance using msgflo.transport.getClient('mytransport://somehost:666'). This has the advantage of also working when specifying the broker URL using msgflo-nodejs --broker or MSGFLO_BROKER= environment variable.

0.11.1

7 years ago

0.11.0

7 years ago

0.10.5

7 years ago

0.10.4

7 years ago

0.10.2

7 years ago

0.10.1

7 years ago

0.10.0

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.2

7 years ago

0.8.1

7 years ago

0.7.2

8 years ago

0.7.1

8 years ago

0.7.0

8 years ago

0.6.0

8 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.4.13

8 years ago

0.4.12

8 years ago

0.4.11

8 years ago

0.4.10

9 years ago

0.4.9

9 years ago

0.4.8

9 years ago

0.4.7

9 years ago

0.4.6

9 years ago

0.4.5

9 years ago

0.4.4

9 years ago

0.4.3

9 years ago

0.4.2

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.0.1

9 years ago