New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

Gusto

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

Gusto

micro services library

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

Gusto

Micro service library

Gusto is a simple micro service library.

Needs node version > 5.00 to work.

TODO. Add more message transport layers.

Add a better pattern matching transport that supports nested objects.

Documentation, more examples...

listen to all messages

'use strict'

const _gusto = require('gusto');
const gusto  = new _gusto();

gusto.connect('global_message_bus', () => {

	gusto.tap('*', (err, message) => {

		// listen to all messages
		console.log(message);
	});
});

listen for a paticular micro service

'use strict'

const _gusto = require('gusto');
const gusto  = new _gusto();

gusto.connect('global_message_bus', () => {

	gusto.tap('{ math: "*" }', (err, message) => {

		// listen to all messages from the math micro service.
		console.log(message);
	});
});

// the math microservice would emit messages like this:

gusto.emit({
	math: {
		result: some_operation(...operands)
	}
});

another example

'use strict'

const _gusto = require('gusto');
const gusto  = new _gusto();

gusto.connect('global_message_bus', () => {
	
	gusto.tap('{ demo: "*" }', (err, message) => {
		if(err) console.log(err);
		let parse    = message.demo.cmd;
		let _parse   = parse.split(':');
		let left_op  = _parse[1].split('_')[0];
		let right_op = _parse[1].split('_')[1];
		let result = parseInt(left_op) + parseInt(right_op);
		gusto.emit({
			math: {
				result: result,
				timestamp: new Date().toISOString()
			}
		});
	});
});

setInterval(()=>{
	let left_op  = Math.floor(Math.random()*11)+5;
	let right_op = Math.floor(Math.random()*11)+5;
	let command  = `add:${left_op}_${right_op}`;
	gusto.emit({
		demo: {
			cmd: command,
			timestamp: new Date().toISOString()
		}
	});
}, 5000);

gusto.tap('*', (err, message) => {
	console.log('[monitor] ', message);
	/*
	[example output]
		[monitor]  { demo: { cmd: 'add:9_5' } }
		[monitor]  { math: { result: 14 } }
		[monitor]  { demo: { cmd: 'add:6_11' } }
		[monitor]  { math: { result: 17 } }
	*/
})

setTimeout(() => {
	console.log('Thanks for trying Gusto!');
	process.exit(0);
}, 45000);

Keywords

micro services

FAQs

Package last updated on 30 Oct 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts