hotelx-seneca-mesh

0.5.0 • Public • Published

Seneca

A Seneca.js transport plugin that uses the SWIM gossip algorithm for automatic configuration of the microservice network.

For a detailed example, see Iteration 05 of the nodezoo workshop.

seneca-mesh

npm version Build Status Gitter

This module is a plugin for the Seneca framework.

If you're using this module, and need help, you can:

If you are new to Seneca in general, please take a look at senecajs.org. We have everything from tutorials to sample apps to help get you up and running quickly.

Install

npm install seneca-balance-client
npm install seneca-mesh

The seneca-mesh plugin depends on the seneca-balance-client plugin.

And in your code:

require('seneca')()
  .use('mesh', { ... options ... })

Test

To run tests, simply use npm:

npm run test

Quick Example

Base node, so that other nodes have a known reference point to join the network.

base.js

require('seneca')()
  .use('mesh',{base:true})
 
// start first!
// $ node base.js

service-foo.js

require('seneca')()
  .add( 'foo:1', function (msg, done) {
    done( null, {x:1,v:100+msg.v} )
  })
 
  // this service handles foo:1 messages
  .use('mesh', { auto:true, pin:'foo:1' })
 
  .ready( function () {
    var seneca = this
 
    setInterval( function() {
 
      // use bar:1, even though location of
      // service-bar is not configured!
      seneca.act('bar:1,v:2', console.log)
    }, 3000 )
  })
 
// $ node service-foo.js

service-bar.js

require('seneca')()
  .add( 'bar:1', function (msg, done) {
    done( null, {x:1,v:100+msg.v} )
  })
 
  // this service handles bar:1 messages
  .use('mesh', { auto:true, pin:'bar:1' })
 
  .ready( function () {
    var seneca = this
 
    setInterval( function() {
 
      // use foo:1, even though location of
      // service-foo is not configured!
      seneca.act('foo:1,v:2', console.log)
    }, 3000 )
  })
 
// $ node service-bar.js

The foo and bar services call each other, but neither requires configuration information!

Examples

You can review the source code of these example projects to see seneca-mesh in action:

Contributing

The Senecajs org encourages open participation. If you feel you can help in any way, be it with documentation, examples, extra testing, or new features please get in touch.

License

Copyright (c) 2015, Richard Rodger and other contributors. Licensed under MIT.

Package Sidebar

Install

npm i hotelx-seneca-mesh

Weekly Downloads

1

Version

0.5.0

License

MIT

Last publish

Collaborators

  • manoj150283