Building Streaming REST APIs with Ruby(intridea.com)
intridea.com
Building Streaming REST APIs with Ruby
http://intridea.com/blog/2012/5/24/building-streaming-rest-apis-with-ruby
4 comments
Actually, it should work. If you see in the other comments, someone mentioned that rack-stream uses faye-websocket-ruby, which has multiple fallbacks.
I would suggest anyone implementing this take a look at faye-websocket. It was recently extracted from a production-quality project named Faye, which uses a pub-sub broadcast model based on bayeux. The websocket implementation has numerous fallbacks, and is well-tested. I'm using it in production currently.
https://github.com/faye/faye-websocket-ruby
https://github.com/faye/faye-websocket-ruby
faye-websocket-ruby's a great project. rack-stream actually uses it to detect websocket and eventsource requests, and stream back on those protocols.
I had no idea. Cool.
Is there any information out there regarding streams / chunked responses within Rails? (I'm not talking about the new template stream facility, but generating arbitrary data)
I'm currently using enumerators assigned to response_body:
I'm currently using enumerators assigned to response_body:
self.status_code = 200
self.response_body = Enumerator.new { |y| ... }
I'm hitting a number of problems though, e.g unicorn killing long-lived workers.[deleted]
Could you link to a fuller gist? Is self referring to an ActionDispatch::Response object? I plan on improving rails integration with rack-stream so that you can call `#chunk` from controllers and that will defer sending a chunk of content.
Here goes: https://gist.github.com/2823045
This is super cool.
This is why socket.io and its contemporaries have several layers of fallbacks, even going back to infinite iframe/JSONP polling.