神刀安全网

embeddable peer 2 peer service discovery and configuration

Galaxya embeddable peer 2 peer service discovery and configuration

embeddable peer 2 peer service discovery and configuration service

Galaxya helps one process or machine discover another, usinggossip

Example

start galaxya from command line (starts on port 25120)

seed

npm install -g galaxya  > galaxya 

service1.js

var galaxya = require('galaxya')({ seeds: [ '127.0.0.1:25120' ] }) galaxya.start(function () {     galaxya.registerService({         port: 12345,         name: 'foo',         version: '1.0.0',         data: {             my: 'service',             data: 1         }     }) })

service2.js

var galaxya = require('galaxya')({ port: 25121, seeds: [ '127.0.0.1:25120' ] }}) galaxya.start(function () {     galaxya.registerService({         port: 1234,         name: 'foo',         version: '0.0.6',         data: {             my: 'service',             data: 1         }     }) })

client.js

var galaxya = require('galaxya')({port: 25123, seeds: [ '127.0.0.1:25122' ]})  galaxya.start(function () {      var services = galaxya.lookupService('foo', '0.0.5')      //services might be     // [     //      { port: 12345, name: 'foo', version: '1.0.0', data: { my: 'service', data: 1 }},     //      { port: 12345, name: 'foo', version: '0.0.6', data: { my: 'service', data: 1 }}     // ]      // discover new foo services     var discovery = galaxya.discoverService('foo')      discovery.on('available', function (service) {         // notify on all foo services     })      discovery.on('available', '0.0.3' function (service) {         // notify on versions equal or higher than 0.0.3         service.on('fail', function () {    })         service.on('alive', function () { })     })      // this also works     galaxya.discoverService('foo', function(err, service) {         // will be fired EACH TIME a 'foo' service will be discovered         // as this might be unconventional, in the future we might change this so it will be called          // only in the first discovery.     }) })

namespacing

// service1.js     galaxya.registerService({         name: 'foo/bar/moo',         port: 1234     })      galaxya.registerService({         name: 'foo/bar',         port: 1234     })      // serviceClient.js     var discovery = galaxya.discoverService('foo/bar')      discovery.on('available', function(service) {         // fires twice, once for foo/bar and once for foo/bar/moo     })

TODO

  • document the 1 to many mapping between gossiper to services topology
  • add auto network space assignment
  • is trie really the right structure for the underlying index?
  • allow for gossiper per machine architecture
  • discoverService callback, first time only or always?
  • add consensus algorithm

转载本站任何文章请注明:转载至神刀安全网,谢谢神刀安全网 » embeddable peer 2 peer service discovery and configuration

分享到:更多 ()

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
分享按钮