Skip to content

possan/node_serviceprovisioner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Node.js service broker and provisioner

Simple scalable example setup

  • one or more provisioning servers (examples/provisioner.js)
  • one or more service proxies per provisioning server (examples/proxy.js)
  • multiple clients (examples/trigger.js)
  • a pubsub-capable messagebus (redis implementation included)

Typical client workflow

  1. client picks a random channel name.
var commchannel = 'mycomm/' + uuid.v1();
  1. client tells the provisioner that it expects a specific service running on that channel.
bus.publish('provisioner', { 
	type: 'provision',
	service: 'randomnumberservice',
	channel: commchannel
});
  1. provisioner then tells one of all available proxies to start that service up on that channel.

  2. client talks directly to service on selected channel.

bus.subscribe(commchannel, function (chan, msg) {
	console.log('message from service:', msg);
});

bus.publish(commchannel, {
	action: 'something',
});

Writing services is also simple

This is a sample service reporting random values back at given intervals to the client, and listens for an killsignal which stops it.

var commchannel = process.argv[2]; // channel name is first argument 
console.log('## Sample service - communicating on channel '+commchannel);

bus.subscribe(commchannel, function (chan, msg) {
	if (msg.type == 'stop-service')
		process.exit();
});
	
setInterval(function () { 
	bus.publish( commchannel, { type:'data', value:Math.random()*1000 } );
}, 2000);

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published