Created
April 18, 2012 03:10
-
-
Save timsavery/2410833 to your computer and use it in GitHub Desktop.
statter
This file contains 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
var amqp = require('amqp'); | |
var connection = amqp.createConnection(); | |
connection.on('ready', function() { | |
connection.exchange('ServiceCalls', { type: 'fanout' }, function(exchange) { | |
connection.queue('AllServiceCalls', function(queue) { | |
queue.bind(exchange, '#'); | |
queue.subscribe(function(message, headers, deliveryInfo) { | |
var filter = eval("(function(m) { \ | |
if (m.service && m.operation) { \ | |
return increment(m.service, m.operation); \ | |
} \ | |
})"); | |
var stat = filter(message); | |
if (stat) { | |
console.log(stat); | |
} | |
}); | |
}); | |
}); | |
}); | |
function increment() { | |
var keyParts=[]; | |
for (var i = 0; i < arguments.length; i++) { | |
keyParts.push(arguments[i]); | |
} | |
return keyParts.join('.') + ':1|c'; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment