JSPM

storm-drpc-node

0.0.3
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q39900F
  • License MIT

Apache storm DRPC client for Node.js

Package Exports

  • storm-drpc-node

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (storm-drpc-node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

storm-drpc-node

Apache storm DRPC client for Node.js

Inspired by node-drpc, but the difference is that it can be optionally set keep alive, it does't need to createConnection in every execute() call, and one can use it in the traditional or promise way as it like.

Install

npm install storm-drpc-node

Usage

var DRPC = require('storm-drpc-node');

var drpcClient = new DRPC(options);

options

  • host: drpc cluster client host

  • port: drpc client port, default to 3772

  • timeout: TCP connection timeout time, default to null

  • keepAlive: keep connect alive, default to true

  • maxConnectCounts: the mximum connect counts, if the param keepAlive is set true, client will reconnect to storm until the connect counts exceed the maxConnectCounts.

Events

  • error: emit when exception occurs

  • close: emit when connect close while conection is keepAlive

  • connect: emit when connection ready

  • timeout: timeout event listener

Methods

  • execute(String spoutName, String emitValue[, Function callback]): call storm drpc cluster by thrift protocol

Example

var DRPC = require('storm-drpc-node');

var client = DRPC({
    host: '127.0.0.1',
    port: 3772,
    timeout: 1000,
    keepAlive: true,
    maxConnectCounts: 30
});

client.on('error', function(err) {
    throw err;
});

// promise way
client.execute('spout-name', JSON.stringify(data))
    .then(function(res) {
        console.log(res);
    })
    .catch(function(err) {
        throw err;
    });

// callback way
client.execute('spout-name', JSON.stringify(data), function(err, res) {
    if(err) throw err;
    else console.log(res);
});

Licence

storm-drpc-node is licenced under the MIT licence.