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

cyclone

v2.0.0

Published

A JavaScript Apache Storm topology implementation.

Downloads

14

Readme

cyclone

Write Storm topologies in JavaScript.

Basic Example

import WordCount from './wordcount';
import SplitSentence from './splitsentence';
import RandomSentence from './randomsentence';
import Cyclone, { TopologyBuilder } from 'cyclone';


let builder = new TopologyBuilder();
builder.setSpout('spout', new RandomSentence());
builder.setBolt('split', new SplitSentence(), 4).shuffleGrouping('spout');
builder.setBolt('count', new WordCount(), 4).fieldsGrouping('split', [ 'word' ]);


Cyclone.run(builder, { name: 'mytopology' });

Spouts

To write a Spout, merely extend the provided Spout class and write your own implementation.

import { Spout } from 'cyclone';

export default class RandomSentence extends Spout {

	declareOutputFields() {
		return [ 'sentence' ];
	}

	nextTuple() {
		let rand = Math.floor(Math.random() * SENTENCES.length);
        this.emit({ tuple: [ SENTENCES[rand] ], anchorTupleId: id });
        done();
	}
}

Default Methods

  • log

  • emit

Overridable Methods

  • declareOutputFields() (optional, defaults to [])

  • getComponentConfiguration() (optional, defaults to {})

  • nextTuple(id, done) (required)

  • ack(id, done) (optional)

  • fail(id, done) (optional)

Bolts

Similar to Spouts, Bolts are created by extending the provided Bolt base class.

import { Bolt } from 'cyclone';

export default class MyBolt extends Bolt {

	declareOutputFields() {
		return [ 'words' ];
	}

	process(tuple, done) {
		let [ sentence ] = tuple.values;
		let words = sentence.split(/\s+/);

        for (let word of words) {
            this.emit({ tuple: [ word ], anchorTupleId: tuple.id });
        }

        done();
	}

}

Default Methods

  • log

  • emit

Overridable Methods

  • declareOutputFields() (optional, defaults to [])

  • getComponentConfiguration() (optional, defaults to {})

  • prepare(config, context, done) (optional)

  • process(tuple, done) (required)

Running a local cluster

To run a local cluster simply run your topology file with the --local flag. For example, if the Basic Example above were your index.js file, simply run $ node . --local. You will need Apache Storm installed and on your path as well as an invocation of run in your topology file:

Cyclone.run(builder, { name: 'mytopology' });

Submitting a Topology

To submit a topology you will need Apache Storm installed an on your path. If that's the case, the easiest way would be to run the cyclone command against your topology using an npm script:

{
	"main": "index.js",
	"scripts": {
		"submit": "cyclone"
	}
}

In this case, the cyclone command will default to using the entrypoint file as identified in the "main" package.json property. Otherwise a topology can be specified using the -t/--topology flag. By default, this submits the topology to the Nimbus host configured in ~/.storm/storm.yaml.

# ~/.storm/storm.yaml
nimbus.host: "255.255.255.255"