Created
June 25, 2013 13:28
-
-
Save neilmiddleton/5858434 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
module HealthReport | |
module LogStreamer | |
def stream(url, timeout) | |
Timeout::timeout(20) do | |
EventMachine.run do | |
EventMachine::PeriodicTimer.new(15) { out << "\0" } | |
http = EventMachine::HttpRequest.new(url, keepalive: true, connection_timeout: 0, inactivity_timeout: 0).get | |
buffer = "" | |
http.stream do |chunk| | |
buffer << chunk | |
yield buffer | |
end | |
end | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment