Created
June 22, 2011 10:57
-
-
Save thattommyhall/1039868 to your computer and use it in GitHub Desktop.
Connecting to ZMQ firehose
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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