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

nodeservicebus

v0.0.5

Published

Node.js Service platform based on NServicebus using Redis as PubSub

Downloads

11

Readme

NodeServiceBus

This project is currently in development and in very early stages. You are welcome to have a play around and offer suggestions.

Install

  npm install nodeservicebus --save

Documentation

About

NodeServiceBus aims to provide you with a service host that you can clone in process (with something like cluster ) or on many different machines. You can use it inside express apps or as standalone processes.

It uses Redis PubSub with a reliable persistence mechanism, which means that messages will be queued until service hosts come back online. The main concept around NodeServiceBus is to allow you to follow the CQRS pattern. NodeServiceBus uses a simple 'Message' and 'MessageHandler' pattern, which allows you to fully control how you structure your logic.

The point of NodeServiceBus is to send messages around the system and have one or many handlers respond (PubSub). Handlers can also send messages which allows everything to be event driven and non-blocking. There is no single 'source of truth' and every component knows only what it has to do (Single Responsibility).

Prerequisites

Install Redis. Support for RedisToGo has been implemented but not yet tested.

Examples

Direct Transport

my-service.js

  var nsb = require('nodeservicebus'),
      myHandlers = require('./my-handlers');

  nsb.service.createService('my service', myHandlers, function(bus) {
    var message = nsb.message.createDirect('cityRequest', 'UK');
    bus.send(message);
  });

city-request.js

  var nsb = require('nodeservicebus');

  module.exports = nsb.handler.createHandler('cityRequest', function(msg, bus){
    console.log('received cities request for '+msg.payload);

    var responseMessage = nsb.message.createDirect('cityResponse', ['London', 'Manchester', 'Birmingham']);
    bus.send(responseMessage);
  });

city-response.js

  var nsb = require('nodeservicebus');

  module.exports = nsb.handler.createHandler('cityResponse', function(msg){
    console.log('received cities  '+msg.payload);
  });

output:

  my service is online
  received cities request for UK
  received cities  London,Manchester,Birmingham

Queued Transport

my-service.js

  var nsb = require('nodeservicebus'),
      myHandlers = require('./my-handlers');

  nsb.service.createService('my service', myHandlers, function(bus) {
    var message = nsb.message.createQueued('cityRequest', 'UK');
    bus.send(message);
  });

city-request.js

  var nsb = require('nodeservicebus');

  module.exports = nsb.handler.createHandler('cityRequest', function(msg, bus){
    console.log('received cities request for '+msg.payload);

    var responseMessage = nsb.message.createQueued('cityResponse', ['London', 'Manchester', 'Birmingham']);
    bus.send(responseMessage);
  });

city-response.js

  var nsb = require('nodeservicebus');

  module.exports = nsb.handler.createHandler('cityResponse', function(msg){
    console.log('received cities  '+msg.payload);
  });

output:

  my service is online
  SUCCESS: PUBLISHER:main_publisher RESULT:1 CHANNEL:message TIMESTAMP:1394362145399
  received cities request for UK
  SUCCESS: SUBSCRIBER:main_subscriber RESULT:Received Message on Default CHANNEL:message TIMESTAMP:1394362145399
  SUCCESS: PUBLISHER:main_publisher RESULT:1 CHANNEL:message TIMESTAMP:1394362145405
  received cities  London,Manchester,Birmingham
  SUCCESS: SUBSCRIBER:main_subscriber RESULT:Received Message on Default CHANNEL:message TIMESTAMP:1394362145405

Roadmap

  • Dependency Injection in Handlers
  • Built in Handlers (eg. Logging, FileWatching, HttpGet and HttpPost, etc...)
  • Admin UI for monitoring all messages and performance
  • Able to record all messages (EventSourcing)
  • WebSocketService (full duplex communication between a front-end such as Angular)
  • Service, handler, message and test generators.

Contributing

In lieu of a formal styleguide, take care to maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code using Grunt.

Credits

The initial scaffold for this module was generated thanks to the Node-Mocha-Star generator (https://github.com/braddenver/generator-node-mocha-star)

Release History

http://www.npmjs.org/package/nodeservicebus

License

Copyright (c) 2014 Marcel du Preez. Licensed under the MIT license.