waterfront

a small but mighty message broker

waterfront

A generic message broker system on top of axon with discovery patterns for push/pull, req/rep, pub/sub, pub-emitter/sub-emitter.

Axon provides low level building blocks for designing messaging patterns. Although easy to build, all the ports to bind and connect to can be difficult to keep track of. Waterfront provides a simple robust messaging pattern with detailt ports.

This method is for standing up a woterfront message broker. It is the centralized component.

var waterfront = require('waterfront').listen()
var waterfront = require('waterfront').connect()

socket returns an axon socket based on the type that is passed in. possible values for type are: push, pull, req, rep, pub, sub, pub-emitter, sub- emitter.

var waterfront = require('waterfront').connect()
var sock       = waterfront.socket("push")
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('push')

setInterval(function(){
  sock.send({ "date" : (+new Date) })
}, 200)
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('pull')

sock.on("message", function(data){
  console.log(data)
})
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('req')

sock.send({ req: +new Date }, function(rep){
  console.log(rep)
  process.exit()
})
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('rep')

sock.on('message', function(data, callback){
  data.rep = +new Date
  callback(data)
})
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket("pub")

setInterval(function(){
  sock.send({ pub: +new Date })
}, 200)
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket("sub")

sock.on("message", function(msg){
  console.log(msg)
})
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('pub-emitter')

setInterval(function(){
  sock.emit( "vancouver", { "date": (+new Date) })
}, 500)
var waterfront = require('waterfront').connect()
var sock       = waterfront.socket('sub-emitter')

sock.on('*', function(channel, data){
  console.log(channel, data)
})