Permalink
Browse files

updated changelog

  • Loading branch information...
tenderlove committed Jul 30, 2012
1 parent fa3c4ea commit 0899be5798d20e3e886e5f741d3e4b1bf43afedd
Showing with 16 additions and 0 deletions.
  1. +16 −0 actionpack/CHANGELOG.md
View
@@ -1,5 +1,21 @@
## Rails 4.0.0 (unreleased) ##
* Added ActionController::Live. Mix it in to your controller and you can
stream data to the client live. For example:
class FooController < ActionController::Base
include ActionController::Live
def index
100.times {
# Client will see this as it's written
response.stream.write "hello world\n"
sleep 1
}
response.stream.close
end
end
* Remove ActionDispatch::Head middleware in favor of Rack::Head. *Santiago Pastorino*
* Deprecate `:confirm` in favor of `:data => { :confirm => "Text" }` option for `button_to`, `button_tag`, `image_submit_tag`, `link_to` and `submit_tag` helpers.

18 comments on commit 0899be5

@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 1, 2012

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?

adsummos replied Aug 1, 2012

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?

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 1, 2012

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?

adsummos replied Aug 1, 2012

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?

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Aug 1, 2012

Member

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

Member

rafaelfranca replied Aug 1, 2012

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

@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 1, 2012

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?

adsummos replied Aug 1, 2012

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?

@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 1, 2012

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.

adsummos replied Aug 1, 2012

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.

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Aug 2, 2012

Member

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.

Member

rafaelfranca replied Aug 2, 2012

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.

@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 2, 2012

adsummos replied Aug 2, 2012

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@rafaelfranca

rafaelfranca Aug 2, 2012

Member

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.

Member

rafaelfranca replied Aug 2, 2012

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.

@tenderlove

This comment has been minimized.

Show comment
Hide comment
@tenderlove

tenderlove Aug 2, 2012

Member

@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.

Member

tenderlove replied Aug 2, 2012

@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.

@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 2, 2012

adsummos replied Aug 2, 2012

@tenderlove

This comment has been minimized.

Show comment
Hide comment
@tenderlove

tenderlove Aug 2, 2012

Member

@adsummos The old method will work the same way, feel free to use it.

Member

tenderlove replied Aug 2, 2012

@adsummos The old method will work the same way, feel free to use it.

@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 2, 2012

I'm just trying to understand if this adds something new, and if so, what that is.

adsummos replied Aug 2, 2012

I'm just trying to understand if this adds something new, and if so, what that is.

@tenderlove

This comment has been minimized.

Show comment
Hide comment
@tenderlove

tenderlove Aug 2, 2012

Member

@adsummos it adds an IO like API for writing to responses.

Member

tenderlove replied Aug 2, 2012

@adsummos it adds an IO like API for writing to responses.

@adsummos

This comment has been minimized.

Show comment
Hide comment
@adsummos

adsummos Aug 2, 2012

so it is just the API? There is no fundamental difference between yield 'response' and response.stream.write 'response' in terms of functionality?

adsummos replied Aug 2, 2012

so it is just the API? There is no fundamental difference between yield 'response' and response.stream.write 'response' in terms of functionality?

@brainopia

This comment has been minimized.

Show comment
Hide comment
@brainopia

brainopia Aug 3, 2012

Contributor

nice, finally streaming api I would use without nightmares :)

Contributor

brainopia replied Aug 3, 2012

nice, finally streaming api I would use without nightmares :)

@femto

This comment has been minimized.

Show comment
Hide comment
@femto

femto Nov 20, 2012

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:inwrite'
...

So I debug a bit and found out the problem,

module ActionController
module Live
class Buffer < ActionDispatch::Response::Buffer #:nodoc:

  def write(string)
    unless @response.committed?
      @response.headers["Cache-Control"] = "no-cache"
      @response.headers.delete "Content-Length"
    end
    #raise IOError, "closed stream" if closed?
    begin
      @response.commit!
      @buf.push string
    rescue
    end
  end
end

end
end

the comment out line is what causes the problem, when commented out,
it's ok, so maybe adding this to fix?

femto replied Nov 20, 2012

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:inwrite'
...

So I debug a bit and found out the problem,

module ActionController
module Live
class Buffer < ActionDispatch::Response::Buffer #:nodoc:

  def write(string)
    unless @response.committed?
      @response.headers["Cache-Control"] = "no-cache"
      @response.headers.delete "Content-Length"
    end
    #raise IOError, "closed stream" if closed?
    begin
      @response.commit!
      @buf.push string
    rescue
    end
  end
end

end
end

the comment out line is what causes the problem, when commented out,
it's ok, so maybe adding this to fix?

@i8igmac

This comment has been minimized.

Show comment
Hide comment
@i8igmac

i8igmac Oct 29, 2016

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)

i8igmac replied Oct 29, 2016

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)

Please sign in to comment.