Skip to content

Instantly share code, notes, and snippets.

View UsamaAshraf's full-sized avatar

Usama Ashraf UsamaAshraf

View GitHub Profile
module.exports = (user) => {
// Send a welcome email or whatever.
}
const myEmitter = require('./my_emitter');
const sendEmailOnRegistration = require('./send_email_on_registration');
const someOtherListener = require('./some_other_listener');
myEmitter.on('user-registered', sendEmailOnRegistration);
myEmitter.on('user-registered', someOtherListener);
const myEmitter = require('./my_emitter');
myEmitter.on('user-registered', (user) => {
// Send an email or whatever.
});
const myEmitter = require('./my_emitter');
// Perform the registration steps
// Pass the new user object as the message passed through by this event.
myEmitter.emit('user-registered', user);
const EventEmitter = require('events');
const myEmitter = new EventEmitter();
module.exports = myEmitter;
public static void main(String[] args) throws Exception
{
TopologyBuilder builder = new TopologyBuilder();
builder.setSpout("word", new TestWordSpout(), 10);
builder.setBolt("exclaim1", new ExclamationBolt(), 3).shuffleGrouping("word");
builder.setBolt("exclaim2", new ExclamationBolt(), 2).shuffleGrouping("exclaim1");
# Telling the Supervisor where the Zookeeper is.
storm.zookeeper.servers:
- "zookeeper"
# The worker nodes need to know which machine(s) are the candidate of master
# in order to download the topology jars.
nimbus.seeds : ["storm-nimbus"]
# For each Supervisor, we configure how many workers run on that machine.
# Each worker uses a single port for receiving messages, and this setting
# The Nimbus needs to know where the Zookeeper is. This specifies the list of the
# hosts in the Zookeeper cluster. We're using just one node, of course.
# 'zookeeper' is the Docker Compose network reference.
storm.zookeeper.servers:
- "zookeeper"
version: '3.2'
services:
zookeeper:
build: ./zookeeper
# Keep it running.
tty: true
storm-nimbus:
build: ./storm-nimbus
package packagename
// …
public class OurSimpleTopology { 
 
public static void main(String[] args) throws Exception
  {
  // Create the topology
  TopologyBuilder builder = new TopologyBuilder();