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

storm-node

v0.2.1

Published

Simple implementation of [storm-multilang protocol](https://github.com/nathanmarz/storm/wiki/Multilang-protocol) for nodeJS apps. Handles reading, emitting, acking, failing, and handshaking.

Downloads

8

Readme

storm-node

Simple implementation of storm-multilang protocol for nodeJS apps. Handles reading, emitting, acking, failing, and handshaking.

At this time, Bolts and Spouts listen to process.stdin and write to process.stdout; they are meant to be run as standalone processes. To override this, change the input and output properties on your Bolt or Spout.

| Version | Compatibility | |----------|----------------| |>= 0.2.0 | Storm 0.9.3+ | |<= 0.2.0 | Storm <= 0.7.0 |

Example

Basic Bolt with automatic ack and anchoring

'use strict';
var util = require('util');
var Storm = require('storm-node');

var TestBolt = function() {
  // Put any init code here.
};
// Inherit BasicBolt for automatic ack & anchoring.
util.inherits(TestBolt, Storm.BasicBolt);

// BasicBolt's `process` method is fed an 'emit' function that
// *must* be used instead of `this.emit`. If you use `this.emit` directly,
// anchoring will not occur.
TestBolt.prototype.process = function(tuple, emit, done) {
  // Use provided `emit` function for automatic anchoring.
  emit(["val1","val2"]);
  // `done` must be called to ack.
  done();
};

var bolt = new TestBolt();
bolt.run();

Raw Bolt usage

'use strict';
var util = require('util');
var Storm = require('storm-node');

var SplitSentenceBolt = function() {
  // Put any init code here.
};
util.inherits(SplitSentenceBolt, Storm.Bolt);

// Optional. If present will be called with storm configuration.
SplitSentenceBolt.prototype.onConfig = function(stormConfig) {

};

// Optional. If present, will be called with topology context.
SplitSentenceBolt.prototype.onContext = function(topologyContext) {

};

SplitSentenceBolt.prototype.process = function(tuple) {
  // Configuration is also available via `this.stormConfig`
  var words = tuple.tuple[0].split(" ");

  for(var i = 0; i < words.length; i++)
  {
    // Pass the incoming `tuple` as the first argument to anchor this emit.
    this.emit(tuple, [words[i]]);
    // Or, without anchoring:
    // this.emit([words[i]]);
  }

  // In a subclass of Storm.Bolt, `ack` must be called manually.
  this.ack(tuple);
  // Or fail.
  // this.fail(tuple);
};

var ssb = new SplitSentenceBolt();

// `run()` will start listening for messages via stdin.
ssb.run();

Notes

storm-node exports four objects:

module.exports = {
  // Internal Communication library shared between Bolts and Spouts.
  // You usually don't need to use this.
  Storm: Storm,

  // A raw bolt. Similar to storm.Bolt in Java.
  // You need to manually ack when using this;
  // good for Bolts that emit more than once.
  Bolt: Bolt

  // Similar to storm.BasicBolt. Automatically
  // acks on callback.
  BasicBolt: BasicBolt,

  // WIP.
  Spout: Spout
}

TODO

  • Implement Spouts

Author

Bryan Peterson - @lazyshot

Contributors

@strml @jandre