Commit Graph

31 Commits

Author SHA1 Message Date
Matthew Draper
d44177d45e Remove Faye mode
No deprecation, because it was never documented.
2016-10-01 15:35:59 +09:30
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
f8477f13bf applies new string literal convention in actioncable/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:15:15 +02:00
Kasper Timm Hansen
754e5bdf87 Make client test run individually.
Require our dependency and forgo the core ext version.
2016-06-28 18:54:30 +02:00
Gaurav Sharma
4db92eed3b client test have not using Pathname and hashwithindifferent access 2016-06-26 01:49:54 +05:30
Matthew Draper
a8df1bc345 Properly support reloading for Action Cable channels 2016-06-02 04:08:48 +09:30
Jeremy Daer
3ba0eec20c
Cable: Extract stream handler construction
* Use separate stream handler builders for easy override and testing.
* Fix worker pool execution that was silently failing since it only
  expected connection receivers.

Sparked by code in #24162.
2016-04-18 23:29:51 -07:00
Jeremy Daer
b168eb5819 Cable message encoding
* Introduce a connection coder responsible for encoding Cable messages
  as WebSocket messages, defaulting to `ActiveSupport::JSON` and duck-
  typing to any object responding to `#encode` and `#decode`.
* Consolidate encoding responsibility to the connection. No longer
  explicitly JSON-encode from channels or other sources. Pass Cable
  messages as Hashes to `#transmit` and rely on it to encode.
* Introduce stream encoders responsible for decoding pubsub messages.
  Preserve the currently raw encoding, but make it easy to use JSON.
  Same duck type as the connection encoder.
* Revert recent data normalization/quoting (#23649) which treated
  `identifier` and `data` values as nested JSON objects rather than as
  opaque JSON-encoded strings. That dealt us an awkward hand where we'd
  decode JSON strings… or not, but always encode as JSON. Embedding
  JSON object values directly is preferably, no extra JSON encoding,
  but that should be a purposeful protocol version change rather than
  ambiguously, inadvertently supporting multiple message formats.
2016-03-31 07:08:16 -07:00
Matthew Draper
bbba0649f5 Merge pull request #23992 from matthewd/em-option
Support faye-websocket + EventMachine as an option
2016-03-04 05:31:48 +10:30
Matthew Draper
fc1b32f8d1 Merge pull request #23976 from danielrhodes/enhancement/ac-ping-to-message-type
ActionCable: Add a "welcome" and "ping" message type
2016-03-02 19:17:57 +10:30
Matthew Draper
a373be9da4 Support faye-websocket + EventMachine as an option 2016-03-02 12:17:15 +10:30
Matthew Draper
185c93eb0c Use AS::Executor / AS::Reloader to support reloading in ActionCable 2016-03-02 02:14:20 +10:30
Daniel Rhodes
53e163dc3f Make ping into a message type
This change makes ping into a message type, which
makes the whole protocol a lot more consistent.

Also fixes hacks on the client side to make this all
work.
2016-03-01 02:48:15 +01:00
Daniel Rhodes
f51cb7eef5 Added welcome message type and fix test hacks 2016-03-01 01:38:35 +01:00
Matthew Draper
6da571add8 Merge pull request #23715 from maclover7/fix-unsubscribe
Fix `unsubscribed` server side behavior
2016-02-19 11:17:51 +10:30
Jon Moss
cefcc0f66e Fix unsubscribed server side behavior
Before this commit, the `unsubscribed` callbacks in Action Cable server
side channels were never called. This is because when a WebSocket
"goodbye" message was sent from the client, the Action Cable server
didn't properly clean up after the now closed WebSocket. This means that
memory could possibly skyrocket with this behavior, since part of this
commit is to properly remove closed subscriptions from the global
subscriptions hash. Say you have 10,000 users currently connected, and
then all 10,000 disconnect -- before this patch, Action Cable would
still hold onto information (and Ruby objects!) for all of these now
dead connections.
2016-02-18 16:26:17 -05:00
Matthew Draper
604fd2cb22 Use a semaphore to signal message availability
The Event hack was too much of a hack: on actually thinking about it,
there's a rather obvious race.
2016-02-19 07:50:42 +10:30
Kasper Timm Hansen
3ae8eb13cb Don't rely on the global server as a receiver.
The `WorkerTest`'s `Receiver` is imporsonating an `ActionCable::Connection::Base`, but
just delegates the logger to `ActionCable.logger`.

This creates a mismatch as the connection requires the logger to be a
`TaggedLoggerProxy`'ied logger, while the server doesn't.

Thus to ensure an exception isn't raised when the worker tries to call `tag`
other tests have to assign a proxied logger to their test server.

Instead of forcing change on other tests, have Receiver adhere to the connection
contract and use a `TaggedLoggerProxy`.

As a consequence remove more setup from the tests.
2016-02-14 17:46:48 +01:00
Kasper Timm Hansen
861ece99bb Default connection class to ActionCable::Connection::Base.
Instead of depending on ApplicationCable::Connection being defined at initialize
we should inject it in the Railtie.

Thus we can kill more setup in the tests too.
2016-02-14 17:46:48 +01:00
Kasper Timm Hansen
661298176c Inject Rails' channel paths in engine.
We were explicitly referencing Rails.root in ActionCable::Server::Configuration.initialize,
thereby coupling ourselves to Rails.

Instead add `app/channels` to Rails' app paths and assign the existent files
to `channel_paths`.

Users can still append to those load paths with `<<` and `push` in `config/application.rb`.

This means we can remove the custom `Dir` lookup in `channel_paths` and the Rails
and root definitions in the tests.
2016-02-14 17:46:48 +01:00
David Heinemeier Hansson
7fe32d28a8 Cant run on an out-of-the-box OSX installation without running out of TOO MANY FILES OPEN 2016-02-05 15:23:34 +01:00
Guillermo Iguaran
d6e0eeb1c6 Merge pull request #23370 from maclover7/actioncable-main-travis-build
Move Action Cable back to the main build
2016-01-31 16:56:03 -05:00
Jon Moss
ddd84f6193 Remove unused method 2016-01-31 16:14:26 -05:00
Matthew Draper
4c38319cc2 Wait for EventMachine to finish starting 2016-02-01 03:01:32 +10:30
Matthew Draper
0ae187961c Use a gentler disconnect
The detach used by close! seems to be making EM very sad on Travis.
2016-01-30 07:51:41 +10:30
Matthew Draper
e6d0d4b1ae Don't bother stopping EM between tests
It's not strictly necessary, and maybe this will help with the current
test failure.
2016-01-30 06:41:14 +10:30
Matthew Draper
4d01cd1545 Keep the socket reference after close
We may still try to send to it.
2016-01-30 03:46:37 +10:30
Matthew Draper
3043601d7a Reduce the client count, in hope of a more consistent test 2016-01-30 03:46:37 +10:30
Matthew Draper
0b94afb075 Be more patient while gathering the expected responses 2016-01-30 03:46:37 +10:30
Matthew Draper
786ed1b3ad Handle more IO errors (especially, ECONNRESET)
Also, address the possibility of the listen thread dying and needing to
be respawned. As a bonus, we now defer construction of the thread until
we are first given something to monitor.
2016-01-30 03:46:37 +10:30
Matthew Draper
ce37de4a19 Add a couple of tests that connect with a WS client 2016-01-30 03:46:37 +10:30