2 ms·
In sufficiently modern versions of Rails you could write: def index self.response_body = Enumerator.new do |socket| 100.times do so
by randomdata 14y ago
In sufficiently modern versions of Rails you could write:
def index
self.response_body = Enumerator.new do |socket|
100.times do
socket << "hello world"
end
end
end
Your API is a little less verbose, I'll give you that, but I don't see why you need Queues and Threads unless the problem actually calls for those things. It still looks like you are writing to a socket either way.
- lloeki 14y agoThat's what I do, encapsulated in a bunch of methods aggregated in a streaming module. Don't forget to set this if you're using nginx (which my module does). headers['X-Accel-Buffering'] = 'no'