Skip to content

Instantly share code, notes, and snippets.

@malditogeek
Created September 5, 2012 10:45
Show Gist options
  • Save malditogeek/3634879 to your computer and use it in GitHub Desktop.
Save malditogeek/3634879 to your computer and use it in GitHub Desktop.
astor proxy
class LibratoProxy
def on_readable(socket, messages)
messages.each {|msg| post_to_librato *msg.copy_out_string.split(' ') }
end
def post_to_librato(channel, metric_in_json)
metric = JSON.parse(metric_in_json)
# call to Librato API
end
end
ctx = EM::ZeroMQ::Context.new(1)
EM::run do
socket = ctx.socket ZMQ::SUB, LibratoProxy.new
socket.identity = "proxy-#{Process.pid}"
socket.connect "tcp://127.0.0.1:8890"
socket.subscribe 'metric'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment