2.0.1 • Published 7 years ago

galaxya v2.0.1

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

Galaxya Build Status

embeddable peer 2 peer service discovery and configuration service

  • Galaxya helps one process or machine discover another, using gossip
  • Galaxya helps one process prepare for discovery of processes that do not exist yet.

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 (in the future!)
	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
	})

Availability

	// serviceClient.js
	var discovery = galaxya.discoverService('foo/bar')

	discovery.on('available', function(service) {
		service.on('fail', function () {

		})

		service.on('alive', function () {

		})
	})

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
2.0.1

7 years ago

2.0.0

8 years ago

1.0.3

9 years ago

1.0.2

9 years ago

1.0.1

9 years ago

1.0.0

9 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.3

10 years ago

0.3.2

10 years ago

0.3.0

10 years ago

0.2.2

10 years ago

0.2.0

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.6

10 years ago

0.0.4

10 years ago

0.0.2

10 years ago