Skip to content

Instantly share code, notes, and snippets.

@bernd
Created December 18, 2012 11:09
Show Gist options
  • Save bernd/4327167 to your computer and use it in GitHub Desktop.
Save bernd/4327167 to your computer and use it in GitHub Desktop.
require 'eventmachine'
require 'json'
require 'net/http'
EM.run do
uri = URI('http://guest:[email protected]:15672/api/overview')
req = Net::HTTP::Get.new(uri.request_uri)
req.basic_auth(uri.user, uri.password)
EM::PeriodicTimer.new(1) do
request = -> {
Net::HTTP.start(uri.hostname, uri.port) {|http| http.request(req) }
}
callback = ->(response) { puts JSON.parse(response.body) }
EM.defer(request, callback)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment