Created
April 6, 2011 22:45
-
-
Save bcg/906701 to your computer and use it in GitHub Desktop.
Revisions
-
bcg created this gist
Apr 6, 2011 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ var zmq = require('zeromq'); s = zmq.createSocket('push'); s.connect('tcp://127.0.0.1:15000'); while (true) { // ZOMG he did it again! s.send(new Buffer("test")); } 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ var zmq = require('zeromq'), util = require('util'), redis = require("redis"), client = redis.createClient(); s = zmq.createSocket('pull'); var count = 0; var time = null; s.bind('tcp://127.0.0.1:15000', function(err) { if (err) throw err; s.on('message', function(data) { client.lpush('q', data.toString()); count++; if (count == 1) { time = new Date(); } if ((count % 10000) === 0) { var t = new Date(); console.log('T: ' + ((t-time)/1000)); time = t; } }); util.puts('Server is up ...'); });