npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

esb-node-driver

v0.1.6

Published

Driver for ESB (Connector)

Downloads

15

Readme

ESB-node-driver

ESB nodejs driver - under heavy development

Installation

You need to install zeromq 4 and google protobuf. And then:

npm install esb-node-driver

You will need a redis server, place his ip into /etc/hosts as domain esb-redis.

Usage

var ESB = require('esb-node-driver');

var esb = new ESB({
	//your hostname, needed for back connection from ESB proxy
	publisherHost: 'h0x91b.toyga.local',
	//some free port for listen on it
	publisherPort: 7786,
	
	//Hostname with redis, redis used for proxy registry, place it in /etc/hosts
	redisHost: 'esb-redis',
	redisPort: 6379
});

esb.on('error', function(err){
	console.log('ESB error', err);
});

esb.on('ready', function(){
	console.log('ESB ready for use');
	
	//register some method that will be accessed from any client ESB
	esb.register('/math/plus', 1, function(data, cb){
		console.log('/math/plus cb #1 is invoked with data: ', data);
		cb(null, data.a + data.b);
	});
	
	//you can register any number of responders for same identifier
	esb.register('/math/plus', 1, function(data, cb){
		console.log('/math/plus cb #2 is invoked with data: ', data);
		cb(null, data.a + data.b);
	});
	
	//pubsub :)
	esb.subscribe('/hello', 1, function(data){
		console.log('get message on channel /hello', data);
	});
	
	setInterval(function(){
		
		//lets invoke method above every second
		esb.invoke('/math/plus', {a: 2, b: 3}, function(err, resp, errStr){
			if(err){
				console.log('error while invoking a /math/plus', err, errStr);
				return;
			}
			console.assert(resp == 5);
			console.log('2+3=%s', resp);
		});
		
		//publish something
		esb.publish('/hello', {foo:'bar', rand: Math.random()});
		
	}, 1000);
});

API

  • ESB.register(<identifier>, <version>, <callback>[ ,options])

    Currently is no options here

  • ESB.invoke(<identifier>, <data>, <callback>[ ,options])

    Options may contain:

    • version - by default version is 1
    • timeout - in ms, by default 15000
  • ESB.publish(<identifier>, <data>[ ,options])

    Options may contain:

    • version - by default version is 1
  • ESB.subscribe(<identifier>, <version>, <callback>)

  • ESB.regQueue(<channelName>, <persistentQueueName>)

    This will make a persistent queue <persistentQueueName> from any publish

  • ESB.unregQueue(<channelName>, <persistentQueueName>)

    This will destroy persistent queue

  • ESB.peek(<channelName>, <persistentQueueName>, <timeoutMs>, <callback>)

    Peek & lock entry from persistent queue for <timeoutMs> or until done callback fired

    • callback -> function(msg, done, msgId)

      msg - message done - done callback, fire it for dequeue msgId - autoincrement id used internally in ESB

Issues

If you get error similar to this

module.js:356
  Module._extensions[extension](this, filename);
                               ^
Error: libzmq.so.3: cannot open shared object file: No such file or directory
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/root/node_modules/ESB-proxy-server/main.js:7:10)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)

You need to add export LD_LIBRARY_PATH="/usr/local/lib:$LD_LIBRARY_PATH" to your ~/.bashrc

Building zmq and protobuf from source

#ZMQ
cd /tmp/
wget http://download.zeromq.org/zeromq-4.0.3.tar.gz
tar -xzvf zeromq-4.0.3.tar.gz
cd zeromq-*
./configure && make && sudo make install
#protobuf
cd /tmp/
wget https://protobuf.googlecode.com/files/protobuf-2.5.0.tar.gz
tar -xzvf protobuf-2.5.0.tar.gz
cd protobuf-2.5.0/
./configure && make && sudo make install