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 = ;var Storm = ; var { // Put any init code here.};// Inherit BasicBolt for automatic ack & anchoring.util; // 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.TestBoltprototype { // Use provided `emit` function for automatic anchoring. ; // `done` must be called to ack. ;}; var bolt = ;bolt;
Raw Bolt usage
'use strict';var util = ;var Storm = ; var { // Put any init code here.};util; // Optional. If present will be called with storm configuration.SplitSentenceBoltprototype { }; // Optional. If present, will be called with topology context.SplitSentenceBoltprototype { }; SplitSentenceBoltprototype { // Configuration is also available via `this.stormConfig` var words = tupletuple0; forvar i = 0; i < wordslength; i++ // Pass the incoming `tuple` as the first argument to anchor this emit. this; // Or, without anchoring: // this.emit([words[i]]); // In a subclass of Storm.Bolt, `ack` must be called manually. this; // Or fail. // this.fail(tuple);}; var ssb = ; // `run()` will start listening for messages via stdin.ssb;
Notes
storm-node
exports four objects:
moduleexports = // 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