-
Notifications
You must be signed in to change notification settings - Fork 21.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fa3c4ea
commit 0899be5
Showing
1 changed file
with
16 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Streaming already exists since 3.1 by passing an object that responds to 'each' to respond_body. Does this duplicate the functionality or does it add something new? Are both methods now supported and if so, when would you use one over the other?
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
http://tenderlovemaking.com/2012/07/30/is-it-live.html
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I read that, however I'm not talking about streaming templates. See answer #2 at http://stackoverflow.com/questions/3507594/ruby-on-rails-3-streaming-data-through-rails-to-client
Is that not exactly the same thing with different syntax? Am I missing something?
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The main difference is that know you can control what is been stream to the user in runtime. In the way that already exists you have to construct the response before send to users
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We currently have an app that streams on 3.1 and 3.2 using the 'each' method and we construct the response as we are sending it because the response is too large to fit in memory and it would run into Heroku's 30 second time limit if we didn't start sending data soon enough. Could you give me an example of something you couldn't do with the existing method that you can do with the new one?
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe the 'each' streaming functionality comes from Rack, so maybe you didn't realize it was there? I can't really see anything that's fundamentally different between the two in terms of functionality. We stream a ~50 GB CSV file using the each method while reading from a DB cursor. Again, maybe I'm missing some new functionality this adds, but I'm not sure what it is.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again the main difference is that now you can control when and what is being sent to the client. Yes, we know that Rack have streaming functionality but these feature are not the same. Think about AC::Live as a socket.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aha! Seem I was missing something. Sorry about that.
I did not participate from the discussion to add this feature and I was talking only with my knowledge about the topic.
I'll try to get more information about the topic, and try to answer with a more grounded knowledge if anyone answer first.
Thank you for the discussion and really sorry to make you loose your time explain me.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adsummos it's about control. Rather than waiting for Rack to pull data from your each method (IOW call your each method), this lets you push data to the response. As @rafaelfranca says, this API is for emulating a socket.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adsummos The old method will work the same way, feel free to use it.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm just trying to understand if this adds something new, and if so, what that is.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@adsummos it adds an IO like API for writing to responses.
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so it is just the API? There is no fundamental difference between yield 'response' and response.stream.write 'response' in terms of functionality?
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice, finally streaming api I would use without nightmares :)
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, @tenderlove, I use this code in puma
(thin seems not work, just hangs), it crashes
whenever the client closes stream(
rails-project/rails/actionpack/lib/action_dispatch/http/response.rb:75:in
write': closed stream (IOError) /rails-project/rails/actionpack/lib/action_controller/metal/live.rb:44:in
write'...
So I debug a bit and found out the problem,
module ActionController
module Live
class Buffer < ActionDispatch::Response::Buffer #:nodoc:
end
end
the comment out line is what causes the problem, when commented out,
it's ok, so maybe adding this to fix?
0899be5
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Im trying your git, i had to change activerecord-deprecated_finders in the gem file
Ran bundle update and bundle install with no errors...
Then ran puma and the error bellow.
Im trying to learn, so i hope to poke around your working example.
Unable to load application: NameError: uninitialized constant Rails::Queueing
/home/bigmac/projects/reloader/config/environments/development.rb:42:in `block in <top (required)>': uninitialized constant Rails::Queueing (NameError)