Created
December 18, 2012 11:09
-
-
Save bernd/4327167 to your computer and use it in GitHub Desktop.
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 '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