Merge Action Cable into master #22586

Merged
merged 513 commits into from Dec 17, 2015

Projects

None yet
@dhh
Member
dhh commented Dec 14, 2015

Working in a branch so everyone in rails/rails can collaborate.

lsylvester and others added some commits Jul 9, 2015
@lsylvester lsylvester Up[date README sample code so there is no syntax error 9f23457
@packagethief packagethief ActionCable.server should always return the same instance 6c0afaf
@packagethief packagethief Freshen Gemfile.lock
Generated from a fresh `bundle install`

* Add websocket-driver
* Update activesupport
* Rename `actioncable` -> `action_cable`
42ac768
@packagethief packagethief Fix CoffeeScript syntax in code examples 502d47d
@rafaelfranca rafaelfranca Merge pull request #7 from lsylvester/update-reame-sample-code-syntax…
…-error

Up[date README sample code so there is no syntax error
66cb385
@rafaelfranca rafaelfranca Merge pull request #8 from packagethief/singleton-server
ActionCable.server should always return the same instance
244c6bf
@rafaelfranca rafaelfranca Merge pull request #9 from packagethief/freshen-gemfile-lock
Freshen Gemfile.lock
a55ed7f
@rafaelfranca rafaelfranca Merge pull request #10 from packagethief/doc-syntax
Fix CoffeeScript syntax in code examples
2253ebd
@lsylvester lsylvester update documentation to use websocket protocol 79b05ae
@lsylvester lsylvester update README to include creating the ApplicationCabel::Channel 496bb38
@seuros seuros Merge pull request #11 from lsylvester/use-websocket-protocol
update documentation to use websocket protocol
3357fcd
@dhh dhh Merge pull request #12 from lsylvester/application-channel-not-defined
update README to include creating the ApplicationCabel::Channel
835209b
@mull mull Update README.md
Fix double ` ```ruby ` within the same code block.
ad5d4b8
@dhh dhh Merge pull request #18 from mull/patch-1
README.md code block fix
0426068
@lsylvester lsylvester Update readme to include requiring the cable js file and rename the e…
…xample file for creating App.cable not conflict with the action cable js libs
6661d78
@seuros seuros Merge pull request #19 from lsylvester/readme-client-example-update
Update readme instructions for js
ae0efc7
@lunks lunks small typo on README.md
celluoid -> celluloid
795e1e4
@guilleiguaran guilleiguaran Merge pull request #24 from lunks/patch-1
small typo on README.md
c2a51a2
@dhh dhh Note the need for a big DB connection pool to match worker pool size 7f9c8ee
@dhh dhh Note that there is no auto-reloading of classes in the cable server 763d499
@dhh dhh Add automatic delegations from channel to connection identifiers cbc7306
@dhh dhh Have to require redis in case it wasnt already 849278d
@dhh dhh Link to example repo fc8bb71
@lifo lifo Load mocha for tests f207245
@lifo lifo Tests for the Channel API 8fde483
@lifo lifo Add actionpack as a dependency 53c82f6
@lifo lifo Add some more tests 1af531d
@lifo lifo More connection tests edc68d7
@lifo lifo Test auth failure b4448e5
@lifo lifo Updated Gemfile.lock 13fb9b8
@lifo lifo Connection identifier tests c7dc339
@lsylvester lsylvester Update readme to remove js from example, copies structure from https:… e681230
@robin850 robin850 Merge pull request #25 from lsylvester/update-readme-to-remove-js
 Update README to use coffeescript  all the time
ed7658f
@lifo lifo Always load all the stub files e1da681
@lifo lifo Tests for channel subscriptions 5689164
@lifo lifo Remove busted tests 05b760d
@jeremy jeremy Move dev dependencies from Gemfile to the gemspec: rake, puma, mocha f1b9095
@lifo lifo Update the README re: tests 729f57a
@lifo lifo Worker tests b75bff4
@lifo lifo Include the module for clearing db connections 2f8a3b5
@lifo lifo Include the connection module after defining the work callback 130b8f9
constXife Add coffee-rails as a dependency. a0048e3
constXife Remove version requirements. c47e628
@tedtoer tedtoer disconnect method added to singleton server 3ac5ed5
@dhh dhh Merge pull request #33 from tedtoer/add-disconnect-to-server
disconnect method added to singleton server
84bd21b
@dhh dhh Clearer doc b257588
@rafaelfranca rafaelfranca Merge pull request #31 from constXife/master
Add coffee-rails as a dependency.
6ee8bb9
@twalpole twalpole Update gems and requires 5d8c848
@dhh dhh Merge pull request #35 from twalpole/gem_updates
Update gems and requires
bdbc91a
@cristianbica cristianbica Improve channel actions dispatcher to allow inheritance/mixins
Fixes #14
a97a1fc
@kaspth kaspth Merge pull request #36 from cristianbica/channel-action-dispatched
Improve channel actions dispatcher to allow inheritance/mixins
3fb1a84
@javan javan Don't unsubscribe on the server when another subscription with the sa…
…me identifier is active
dc4f8b3
@javan javan Use Celluloid 0.16.0 until termination issue in 0.17.0 is resolved ccfb1a8
@dhh dhh Merge pull request #37 from rails/downgrade-celluloid
Use Celluloid 0.16.0 until termination issue in 0.17.0 is resolved
f94531a
@maclover7 maclover7 Update README.md
This includes small styling / grammar changes to the README
319c439
@craigsheen craigsheen Move VERSION constant to version file and use this in the gemspec 00ba651
@craigsheen craigsheen require new version file so the constant is available to the application fa7292e
@matthewd matthewd Merge pull request #41 from craigsheen/move_version_to_version_file
Move VERSION constant to version file and use this in the gemspec
437ed97
@lsylvester lsylvester add broadcast_to and stream_for methods as per #26 5954fd1
@kaspth kaspth Merge pull request #34 from lsylvester/add-broadcast_to-and-stream_fo…
…r-methods-to-channel

add broadcast_to and stream_for methods as per #26
ae61460
@kaspth kaspth Run tests with Travis. 0a6787e
@kaspth kaspth Merge pull request #45 from kaspth/run-travis
Run tests with Travis.
b1146a7
@kaspth kaspth Fix the gem version in Gemfile.lock 65fde3b
@lsylvester lsylvester refactor channel look up to use a hash instead of an array and reduce…
… the number of calls to safe_constantize because it can be slow
60e2fa5
@kaspth kaspth Merge pull request #42 from lsylvester/channel-lookup-refactor
Optimize channel class lookup
0c30d87
@rajcybage rajcybage [ci skip] small description on readme for identified_by 123fc0d
@jasondew jasondew Fixing some documentation, correcting grammar, and removing unnecessa…
…ry whitespace
8544df9
@jasondew jasondew Fixes test failure in ActionCable::Channel::BroadcastingTest when run…
… by itself
92b0a99
@dhh dhh Merge pull request #48 from jasondew/documentation_and_whitespace_fixes
Fixing documentation, correcting grammar, and removing unnecessary whitespace
219c48e
@kaspth kaspth Merge pull request #49 from jasondew/channel_broadcasting_test_fix
Fixes test failure in ActionCable::Channel::BroadcastingTest when run by itself
01ca41e
@lsylvester lsylvester update docs for broadcast_to to pass a message to broadcast. 26de1dd
@kaspth kaspth Merge pull request #50 from lsylvester/fix-stream-for-documentation
update docs for broadcast_to to pass a message.
af34e9b
@lsylvester lsylvester move the require of object/to_param to channel/broadcasting because t…
…hat is where it is needed.
9c9f3a5
@kaspth kaspth Merge pull request #54 from lsylvester/require-to_param
Move require of to_param to where it is needed
edbef56
@rafaelfranca rafaelfranca Merge pull request #39 from maclover7/patch-1
Update README.md
0223870
@lsylvester lsylvester log to stdout in development mode. 84e7d76
@lsylvester lsylvester Clear out the streams when they are stopped. Otherwise we will keep t…
…rying to stop them.
8fcdfc3
@dhh dhh Merge pull request #58 from lsylvester/clear-out-stopped-streams
Clear out the streams when they are stopped.
4a9bf9b
@kaichen kaichen Remove out-of-date AC::Broadcaster reference
Remove out-of-data autoload reference of ActionCable::Broadcaster that removed at e1a99a8 .
f2c270c
@dhh dhh Merge pull request #59 from kaichen/patch-1
Remove out-of-date AC::Broadcaster reference
6143352
@javan javan Immediately reconnect when visibilityState changes to "visible" fa362c7
@javan javan Record last 20 Subscription notifications for inspection 5ee5e41
@mrlhumphreys mrlhumphreys support connection identifiers that don't implement to_global_id by d…
…efaulting to to_s
c74f8df
@kaspth kaspth Merge pull request #65 from mrlhumphreys/support-identifiers-without-…
…to-global-id

Support connection identifiers that don't implement to_global_id
b91d0e8
@mieko mieko Use ActiveSupport::Callbacks for Channel subscription callbacks.
 * Rely on AS::Callbacks for callback handling.
 * Add before_subscribe, after_subscribe, before_unsubscribe and
   after_unsubscribe convenience methods
 * alias on_subscribe and on_unsubscribe to after_subscribe and
   after_unsubscribe, respectively.
 * Remove `subscribed` and `unsubscribed` from the callback chain:
   these methods are now executed as the subject of the callbacks.
 * Update portions of ActionCable to use the more specific
   callback names.
cf426a7
@javan javan Simplify WebSocket reconnects and guard against opening multiple conn…
…ections
1379e97
@javan javan Only send "disconnected" notification once ddfd649
@javan javan Immediately reconnect after first disconnect f4b5a4e
@javan javan Guard against opening multiple connections 9e0c0af
@javan javan Increment style 60adbaf
@javan javan Merge branch 'better-reconnect' 0cf1db6
@rafaelfranca rafaelfranca .js.coffee -> .coffee
 It was initially required, but support for the shorthand has been
 supported since sprockets 2.1. Eventually 4.x will only support the
 shorthand version. Just want to get new people using the prefer stuff
 ASAP.
eb8c713
@rafaelfranca rafaelfranca Merge pull request #71 from rails/coffee-only
.js.coffee -> .coffee
4bfe1ab
@jeremy jeremy EventMachine: shush epoll warnings by checking for support before ena…
…bling. Ditto for kqueue.
98855fe
@gregmolnar gregmolnar use correct filename in example
closes #80
6707819
@eileencodes eileencodes Merge pull request #83 from gregmolnar/readme_fix
use correct filename in example
91d6db3
@alexpeattie alexpeattie Fix NoMethodError when using a custom Rails.logger class fdbf759
@lifo lifo First take at cross site forgery protection 0431717
@lifo lifo Use Array() instead of Array.wrap 8275cfb
@lifo lifo Run a single eventmachine timer to send heartbeats b099a7d
javan and others added some commits Nov 6, 2015
@javan javan Share internal identifiers and message types with the JavaScript client 365891d
@javan javan Merge pull request #117 from rails/shared-constants
Share internal identifiers and message types with the JavaScript client
63cdbf8
@kaspth kaspth Tune whitespace in README.md
* Realign `end` statements with the opening `class` statement.
* Pad JavaScript objects with spaces to match Rails styleguide and for consistency with other examples.
6be2604
Jan Habermann Use to_gid_param for connection identifiers 952887a
@lsylvester lsylvester Handle cases where logger is not a tagged logger.
Previously, a TaggedLoggerProxy was only created if the logger responded to
:tagged, but was still used as if it was a TaggedLoggerProxy elsewhere in the
code, causing undefined method  errors.

This moved the check for tagging abilities inside the TaggedLoggerProxy so the
code can always tread the logger like a tagged logger, and if it is not a
tagged logger the tags will just be ignored. This prevents needing to check
if the logger is tagged every time we use it.
43c6c77
@mikecarroll mikecarroll Add README.md instructions on configuring ActionCable.server.config.a…
…llowed_request_origins
e17b65e
@ma2gedev ma2gedev fix typo 6bd458d
@rafaelfranca rafaelfranca Merge pull request #128 from ma2gedev/patch1
fix typo
928aed6
@assimovt assimovt Update README find_verified_user example a3d293b
@dhh dhh Merge pull request #133 from assimovt/master
Update README find_verified_user example
0e283fe
@dhh dhh Merge pull request #126 from mikecarroll/add_allowed_request_origins_…
…to_readme

README.md instructions for configuring allowed request origins
2b4aa9a
@dhh dhh Merge pull request #125 from lsylvester/handle-custom-loggers
Handle cases where logger is not a tagged logger.
cf4d9aa
@dhh dhh Merge pull request #115 from habermann24/master
Fix an error when using multiple gid identifiers
a86d506
@dhh dhh Merge pull request #57 from lsylvester/log-to-stdout-in-developement-…
…mode

Add logging to stdout in development mode.
c362bea
@gregmolnar gregmolnar add devise example to readme 3816fac
@javan javan Freshen up the client-side subscription examples. Fixes #118 14628ff
@javan javan Associate comments with `perform` 2b33675
@smellsblue smellsblue Easy websocket url configuration
Thanks to feedback from @ascrazy, @jeremy, and @javan
62250e3
@adamliesko adamliesko Allow regexp for a allowed_request_origins array 09e10ef
@adamliesko adamliesko Remove unused method allowed_origins in Connection::Base 1c6fb5e
@dhh dhh Merge pull request #130 from adamliesko/allow_regexps_allowed_origins
Allow regexp for a allowed_request_origins array
5fec4b9
@dhh dhh Merge pull request #73 from smellsblue/websocket-url-differentiation
Easy websocket url configuration
7328aa4
@dhh dhh Merge pull request #135 from gregmolnar/readme
add devise example to readme
a890c81
@dhh dhh Merge pull request #137 from rails/freshen-client-side-examples
Freshen up the client-side subscription examples. Fixes #118
4073a3e
@dhh dhh Get ready to merge into Rails bf40bdd
@dhh dhh Initial stab at adding Action Cable to rails/master
760de78
claudiob and others added some commits Dec 14, 2015
@claudiob claudiob Remove Alpha disclaimer from ActionCable
[ci skip] Getting to ready to merge into rails/rails
f6fb71a
@rafaelfranca rafaelfranca Remove action cable gems that are already in the gemspec 2e701a0
@rafaelfranca rafaelfranca Add action_cable to rails/all and application.rb
3cf7b30
@rafaelfranca rafaelfranca Update Gemfile.lock
ccc8055
@rafaelfranca rafaelfranca Add Action Cable tests to travis matrix
a0e4d5e
@rafaelfranca rafaelfranca Require the top level file in the engine f8058a6
@rafaelfranca rafaelfranca Hook in ActionView::Base, not in ApplicationController
The application can have more than one ApplicationController and we
want Action Cable helpers in all controllers and their views so we
should hook in the same place that others helpers.
3d4a423
@rafaelfranca rafaelfranca Do not run action cable tests in isolation
We don't have isolation tests for it yet.
f1ba586
@tubbo
tubbo commented Dec 14, 2015

It is Time.now.zone.

rafaelfranca and others added some commits Dec 15, 2015
@rafaelfranca rafaelfranca Add option to skip Action Cable
65f65d6
@tjblonsk @dhh tjblonsk Add specific bug reporting guidelines to contributing.md. [ci skip]
Add boldface and bullets to make more readable.

Make sentences declarative.

Remove "you"s.
0aae9c2
@sgrif @dhh sgrif Deprecate limit strings with commas
Some backends allow `LIMIT 1,2` as a shorthand for `LIMIT 1 OFFSET 2`.
Supporting this in Active Record massively complicates using bind
parameters for limit and offset, and it's trivially easy to build an
invalid SQL query by also calling `offset` on the same `Relation`.

This is a niche syntax that is only supported by a few adapters, and can
be trivially worked around by calling offset explicitly.
e12c2a6
@sgrif @dhh sgrif Use a bind param for `LIMIT` and `OFFSET`
We currently generate an unbounded number of prepared statements when
`limit` or `offset` are called with a dynamic argument. This changes
`LIMIT` and `OFFSET` to use bind params, eliminating the problem.

`Type::Value#hash` needed to be implemented, as it turns out we busted
the query cache if the type object used wasn't exactly the same object.

This drops support for passing an `Arel::Nodes::SqlLiteral` to `limit`.
Doing this relied on AR internals, and was never officially supported
usage.

Fixes #22250.
af3dc42
@dhh dhh Switch from engine to railtie a8db032
@javan javan Bring latest changes over from actioncable/master 8625518
@dhh dhh Merge pull request #22600 from javan/update-action-cable
Bring latest changes over from actioncable/master
5b56abb
@rafaelfranca rafaelfranca Action Cable need to be a engine
Otherwise assets will not work
ff370ee
@rafaelfranca rafaelfranca Merge remote-tracking branch 'origin/master' into merge-action-cable
ca8e148
@claudiob claudiob Remove rails/actioncable Travis badge
[ci skip]

Since Action Cable is getting integrated into rails/rails, the Travis
badge for rails/actioncable is not needed anymore.

Also following the standard of every other README to have `--` rather
than `-` to separating the name of the library from its description.
70e593d
@claudiob claudiob Add Action Cable to README.md of Rails
[ci skip] Link to actioncable/README.md for more details
98087a6
@claudiob claudiob added this to the 5.0.0 milestone Dec 15, 2015
rafaelfranca and others added some commits Dec 15, 2015
@rafaelfranca rafaelfranca Accept a Pathname in Application#config_for
That would make possible to use it with action cable configuration.
fc635b5
@rafaelfranca rafaelfranca Configure the Action Cable's redis in the engine
This will decouple Action Cable from Rails.
9645534
@rafaelfranca rafaelfranca Remove the default logger
It should be configured through the railtie
23faa71
@rafaelfranca rafaelfranca Move the require to the right place
649b9d9
@dhh dhh Basic channel generator
40cc725
@dhh dhh We are using railtie, not engine 346a752
@dhh dhh Move Cable to ActionCable for client-side constant to avoid conflicts
26bcf81
@dhh dhh Include changes made to the engine
deac988
@dhh dhh Another bad reference to engine instead of railtie
3784068
@dhh dhh Only initialize redis if the config file is there
6bfd191
@dhh dhh Doh, should have read ff370ee
Indeed we need this to be an engine for the internal assets to work
51ad579
@rafaelfranca rafaelfranca Fix the engine reference
3354b2d
@dhh dhh Fix parent class aae14ab
@dhh dhh Assume that the cable server is running in-process by default, offer …
…option to change that in config/environments/production.rb
7eb1279
@dhh dhh Another stab at only mounting redis if the config is there 910572f
@dhh dhh @App could have been set elsewhere
8e9b7c0
@dhh dhh Note that changes to the cable setup requires restarting the server
0625d77
@dhh dhh Simpler directory structure 70be248
@dhh dhh Require tree
0036cb3
@dhh dhh Include the action cable URL meta tag by default
21e0e68
@dhh dhh Needless whitespace
5f02b15
@rafaelfranca rafaelfranca Only include action cable meta tags if it is not skipped 97e4130
@rafaelfranca rafaelfranca Merge branch 'master' into merge-action-cable
4b669db
@dhh dhh Cargo cult fix to make Celluloid behave 59db9eb
@dhh dhh Add default redis config for Action Cable c9c9a60
@dhh dhh By default, mount Action Cable on the router f229d04
@dhh dhh Only mount the ActionCable server if ApplicationCable has been defined d1d1e30
@dhh dhh Eager loading is required for Action Cable and we should use the logg…
…ing too
c0b901e
@dhh dhh Comment out the user handling so default setup connects directly bf16ec2
@dhh dhh Use puma as the default development server, if available
ae48ea6
@dhh dhh Saner increments 6357437
@dhh dhh Generate all the ApplicationCable stubs by default, like all other Ap…
…plication* stubs
28035db
@dhh dhh Clarify a220747
@dhh dhh No longer needed now that we prefill with app/models/application_reco…
…rd.rb
a70331c
@dhh dhh Avoid Action Cable stubs on --skip-action-cable
Still missing the stuff in app/ – we need to basically switch from a *
match to specifically picking out what we need.
eea6f7b
@dhh dhh Quiet warnings 3a83097
@dhh dhh Fix test now that cable is in there by default too
42b9126
@rafaelfranca rafaelfranca No need to check for puma
Rack::Server already does it work for us if the server is installed.
5e406a3
@dhh dhh Fix test
60bbd15
@dhh dhh No longer uses keep now that we have ApplicationRecord
457f92e
@dhh dhh Don't mount the ActionCable server by default
Since we require you to enable it on the client-side, let us do the
same on the server-side. Then you’re not running an EventMachine unless
you need to.
7cf856e
@dhh dhh Fix tests
d15de0c
@dhh dhh merged commit 48f5cec into master Dec 17, 2015

2 checks passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
continuous-integration/travis-ci/push The Travis CI build passed
Details
@dhh dhh deleted the merge-action-cable branch Dec 17, 2015
@rafaelfranca rafaelfranca modified the milestone: 5.0.0 [temp], 5.0.0 Dec 30, 2015
@claudiob
Member

Hello @rafaelfranca -- I was curious about this commit. Why do we use a file called railtie.rb in every module but a file called engine.rb in Action Cable?

Based on 346a752 I thought we would simply rename action_cable/engine.rb to action_cable/railtie.rb.

Thanks!

Member

Good question @claudiob - what are the differences between engines and railties? It looks like Rails::Engine just inherits from Rails::Railtie, and adds some extra functionality.

Member

The differences between Engine and Railtie are exactly the extra functionality 😄.

We can't use a Railtie for Action Cable because it includes JavaScript code. The main difference between an Engine and a Railtie is that Engines can have models, views, controller, helpers, initializers, migrations and assets. We need assets support for Action Cable.

I explained it here ff370ee

@TikiTDO

Is there a reason for the unless @disconnectedRecently() in the reconnectIfStale method here? I am writing my own implementation of these scripts because my requirements need more direct access to the web socket, and this is the only part that I can't see a purpose for. Any chance you could clarify the thought process here?

Member
javan replied May 23, 2016 edited

It's to avoid a "thundering herd" of connections when the server closes the socket. When deploying new code and restarting the server, for example. If every client immediately reconnected onclose there'd be a flood of new connections. Instead, we let ConnectionMonitor's timer detect the stale connection and reconnect, which naturally distributes the connections thanks to the randomness of when each client's timer started.

I am writing my own implementation of these scripts because my requirements need more direct access to the web socket

FYI you can access the WebSocket directly: App.cable.connection.webSocket.

Ah, thank you. That makes a lot more sense.

Unfortunately just access to the socket object wouldn't be enough. My use case would need to replace all the event handlers, and inject a few callbacks in the monitor at the very least. This app is also running on a platform that has access to Promises and Proxies, which simplifies life a bit.

I can share the finish result if you're interested, thought I doubt it would be of any use outside of my application.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment