Skip to content

Instantly share code, notes, and snippets.

@thattommyhall
Created June 22, 2011 10:57
Show Gist options
  • Save thattommyhall/1039868 to your computer and use it in GitHub Desktop.
Save thattommyhall/1039868 to your computer and use it in GitHub Desktop.
Connecting to ZMQ firehose
tail = (channel, callback) ->
socket = require('zeromq').createSocket('sub')
socket.connect("tcp://IP_ADDRESS:5555")
socket.subscribe(channel)
socket.on 'message', (ch, data) -> callback(JSON.parse(data.toString('utf8')))
tail 'channame', (row) -> console.log(row)
require 'rubygems'
require 'ffi-rzmq'
context = ZMQ::Context.new(1)
subscriber = context.socket(ZMQ::SUB)
subscriber.connect("tcp://IP_ADDRESS:5555")
subscriber.setsockopt(ZMQ::SUBSCRIBE, "")
count = 0
start = Time.now
while true do
body = subscriber.recv_string
puts body
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment