actioncable 6.0.0.beta1 → 6.0.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 20a6bcfcf415a9ea43c5d5c373f866bbef09a40408f9295e0977def92827b56f
4
- data.tar.gz: ab61cfc6789eeba117d09b5472adb861d8afaade19486e6bd4b2f34917d13596
3
+ metadata.gz: d61cfd8a951dcbc35e2450a62475a6dea2dc059ebb51d3d21a648ccd9d818c9c
4
+ data.tar.gz: 30e24d4dd9dbcfdb6ac4ebbe819a0f0308eeb5eedd727b0c6598bc47effb3453
5
5
  SHA512:
6
- metadata.gz: 0fc74fe87659a01fbbb841a36de8bd2027d2c3ec73ea92f23706ae07bc8648e5c92cb1bd08bb4f6e00cbbab2c201db183badb1cecae8d7b4839232116fc43e24
7
- data.tar.gz: b09eb6b5430aa9fe60eb41aa8a9e21ad59a49bf281f14cbcf562200ae09e9d2950cc0eb3ebc2d6019f506325cab1c7ff58ea735d4672643ca2de76fd99b86524
6
+ metadata.gz: 95e30afea43f44945441516e8c31addc44e18bce6ded0f8c7cfbaf0822a2085709d2e57913e8ca6bfc126c8504ac4bf32a20a8fda5e81ef91bbb3627919a5bfe
7
+ data.tar.gz: 92ee404ecb7decd93082644943614a8d1a9568d34c9dc185cdeb7030603694c7e665e7f07e64c30c7a7fad47a039b6c8be545a216ec6bc41b44b84d5fa679bac
data/CHANGELOG.md CHANGED
@@ -1,5 +1,74 @@
1
+ ## Rails 6.0.0.beta2 (February 25, 2019) ##
2
+
3
+ * PostgreSQL subscription adapters now support `channel_prefix` option in cable.yml
4
+
5
+ Avoids channel name collisions when multiple apps use the same database for Action Cable.
6
+
7
+ *Vladimir Dementyev*
8
+
9
+ * Allow passing custom configuration to `ActionCable::Server::Base`.
10
+
11
+ You can now create a standalone Action Cable server with a custom configuration
12
+ (e.g. to run it in isolation from the default one):
13
+
14
+ ```ruby
15
+ config = ActionCable::Server::Configuration.new
16
+ config.cable = { adapter: "redis", channel_prefix: "custom_" }
17
+
18
+ CUSTOM_CABLE = ActionCable::Server::Base.new(config: config)
19
+ ```
20
+
21
+ Then you can mount it in the `routes.rb` file:
22
+
23
+ ```ruby
24
+ Rails.application.routes.draw do
25
+ mount CUSTOM_CABLE => "/custom_cable"
26
+ # ...
27
+ end
28
+ ```
29
+
30
+ *Vladimir Dementyev*
31
+
32
+ * Add `:action_cable_connection` and `:action_cable_channel` load hooks.
33
+
34
+ You can use them to extend `ActionCable::Connection::Base` and `ActionCable::Channel::Base`
35
+ functionality:
36
+
37
+ ```ruby
38
+ ActiveSupport.on_load(:action_cable_channel) do
39
+ # do something in the context of ActionCable::Channel::Base
40
+ end
41
+ ```
42
+
43
+ *Vladimir Dementyev*
44
+
45
+ * Add `Channel::Base#broadcast_to`.
46
+
47
+ You can now call `broadcast_to` within a channel action, which equals to
48
+ the `self.class.broadcast_to`.
49
+
50
+ *Vladimir Dementyev*
51
+
52
+ * Make `Channel::Base.broadcasting_for` a public API.
53
+
54
+ You can use `.broadcasting_for` to generate a unique stream identifier within
55
+ a channel for the specified target (e.g. Active Record model):
56
+
57
+ ```ruby
58
+ ChatChannel.broadcasting_for(model) # => "chat:<model.to_gid_param>"
59
+ ```
60
+
61
+ *Vladimir Dementyev*
62
+
63
+
1
64
  ## Rails 6.0.0.beta1 (January 18, 2019) ##
2
65
 
66
+ * [Rename npm package](https://github.com/rails/rails/pull/34905) from
67
+ [`actioncable`](https://www.npmjs.com/package/actioncable) to
68
+ [`@rails/actioncable`](https://www.npmjs.com/package/@rails/actioncable).
69
+
70
+ *Javan Makhmali*
71
+
3
72
  * Merge [`action-cable-testing`](https://github.com/palkan/action-cable-testing) to Rails.
4
73
 
5
74
  *Vladimir Dementyev*
@@ -307,3 +307,5 @@ module ActionCable
307
307
  end
308
308
  end
309
309
  end
310
+
311
+ ActiveSupport.run_load_hooks(:action_cable_channel, ActionCable::Channel::Base)
@@ -7,22 +7,32 @@ module ActionCable
7
7
  module Broadcasting
8
8
  extend ActiveSupport::Concern
9
9
 
10
- delegate :broadcasting_for, to: :class
10
+ delegate :broadcasting_for, :broadcast_to, to: :class
11
11
 
12
12
  module ClassMethods
13
13
  # Broadcast a hash to a unique broadcasting for this <tt>model</tt> in this channel.
14
14
  def broadcast_to(model, message)
15
- ActionCable.server.broadcast(broadcasting_for([ channel_name, model ]), message)
15
+ ActionCable.server.broadcast(broadcasting_for(model), message)
16
16
  end
17
17
 
18
- def broadcasting_for(model) #:nodoc:
18
+ # Returns a unique broadcasting identifier for this <tt>model</tt> in this channel:
19
+ #
20
+ # CommentsChannel.broadcasting_for("all") # => "comments:all"
21
+ #
22
+ # You can pass any object as a target (e.g. Active Record model), and it
23
+ # would be serialized into a string under the hood.
24
+ def broadcasting_for(model)
25
+ serialize_broadcasting([ channel_name, model ])
26
+ end
27
+
28
+ def serialize_broadcasting(object) #:nodoc:
19
29
  case
20
- when model.is_a?(Array)
21
- model.map { |m| broadcasting_for(m) }.join(":")
22
- when model.respond_to?(:to_gid_param)
23
- model.to_gid_param
30
+ when object.is_a?(Array)
31
+ object.map { |m| serialize_broadcasting(m) }.join(":")
32
+ when object.respond_to?(:to_gid_param)
33
+ object.to_gid_param
24
34
  else
25
- model.to_param
35
+ object.to_param
26
36
  end
27
37
  end
28
38
  end
@@ -99,7 +99,7 @@ module ActionCable
99
99
  # Pass <tt>coder: ActiveSupport::JSON</tt> to decode messages as JSON before passing to the callback.
100
100
  # Defaults to <tt>coder: nil</tt> which does no decoding, passes raw messages.
101
101
  def stream_for(model, callback = nil, coder: nil, &block)
102
- stream_from(broadcasting_for([ channel_name, model ]), callback || block, coder: coder)
102
+ stream_from(broadcasting_for(model), callback || block, coder: coder)
103
103
  end
104
104
 
105
105
  # Unsubscribes all streams associated with this channel from the pubsub queue.
@@ -143,7 +143,7 @@ module ActionCable
143
143
  # You need to set up your connection manually to provide values for the identifiers.
144
144
  # To do this just use:
145
145
  #
146
- # stub_connection(user: users[:john])
146
+ # stub_connection(user: users(:john))
147
147
  #
148
148
  # == Testing broadcasting
149
149
  #
@@ -157,9 +157,9 @@ module ActionCable
157
157
  # end
158
158
  #
159
159
  # def test_speak
160
- # subscribe room_id: rooms[:chat].id
160
+ # subscribe room_id: rooms(:chat).id
161
161
  #
162
- # assert_broadcasts_on(rooms[:chat], text: "Hello, Rails!") do
162
+ # assert_broadcasts_on(rooms(:chat), text: "Hello, Rails!") do
163
163
  # perform :speak, message: "Hello, Rails!"
164
164
  # end
165
165
  # end
@@ -300,9 +300,7 @@ module ActionCable
300
300
  def broadcasting_for(stream_or_object)
301
301
  return stream_or_object if stream_or_object.is_a?(String)
302
302
 
303
- self.class.channel_class.broadcasting_for(
304
- [self.class.channel_class.channel_name, stream_or_object]
305
- )
303
+ self.class.channel_class.broadcasting_for(stream_or_object)
306
304
  end
307
305
  end
308
306
 
@@ -260,3 +260,5 @@ module ActionCable
260
260
  end
261
261
  end
262
262
  end
263
+
264
+ ActiveSupport.run_load_hooks(:action_cable_connection, ActionCable::Connection::Base)
@@ -42,8 +42,6 @@ module ActionCable
42
42
 
43
43
  class TestRequest < ActionDispatch::TestRequest
44
44
  attr_accessor :session, :cookie_jar
45
-
46
- attr_writer :cookie_jar
47
45
  end
48
46
 
49
47
  module TestConnection
@@ -10,7 +10,7 @@ module ActionCable
10
10
  MAJOR = 6
11
11
  MINOR = 0
12
12
  TINY = 0
13
- PRE = "beta1"
13
+ PRE = "beta2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -12,14 +12,17 @@ module ActionCable
12
12
  include ActionCable::Server::Broadcasting
13
13
  include ActionCable::Server::Connections
14
14
 
15
- cattr_accessor :config, instance_accessor: true, default: ActionCable::Server::Configuration.new
15
+ cattr_accessor :config, instance_accessor: false, default: ActionCable::Server::Configuration.new
16
+
17
+ attr_reader :config
16
18
 
17
19
  def self.logger; config.logger; end
18
20
  delegate :logger, to: :config
19
21
 
20
22
  attr_reader :mutex
21
23
 
22
- def initialize
24
+ def initialize(config: self.class.config)
25
+ @config = config
23
26
  @mutex = Monitor.new
24
27
  @remote_connections = @event_loop = @worker_pool = @pubsub = nil
25
28
  end
@@ -8,6 +8,8 @@ require "digest/sha1"
8
8
  module ActionCable
9
9
  module SubscriptionAdapter
10
10
  class PostgreSQL < Base # :nodoc:
11
+ prepend ChannelPrefix
12
+
11
13
  def initialize(*)
12
14
  super
13
15
  @listener = nil
@@ -1,15 +1,15 @@
1
1
  import consumer from "./consumer"
2
2
 
3
3
  consumer.subscriptions.create("<%= class_name %>Channel", {
4
- connected: function() {
4
+ connected() {
5
5
  // Called when the subscription is ready for use on the server
6
6
  },
7
7
 
8
- disconnected: function() {
8
+ disconnected() {
9
9
  // Called when the subscription has been terminated by the server
10
10
  },
11
11
 
12
- received: function(data) {
12
+ received(data) {
13
13
  // Called when there's incoming data on the websocket for this channel
14
14
  }<%= actions.any? ? ",\n" : '' %>
15
15
  <% actions.each do |action| -%>
@@ -1,6 +1,6 @@
1
1
  // Action Cable provides the framework to deal with WebSockets in Rails.
2
2
  // You can generate new channels where WebSocket features live using the `rails generate channel` command.
3
3
 
4
- import ActionCable from "@rails/actioncable"
4
+ import { createConsumer } from "@rails/actioncable"
5
5
 
6
- export default ActionCable.createConsumer()
6
+ export default createConsumer()
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actioncable
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.0.0.beta1
4
+ version: 6.0.0.beta2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pratik Naik
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2019-01-18 00:00:00.000000000 Z
12
+ date: 2019-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: actionpack
@@ -17,14 +17,14 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 6.0.0.beta1
20
+ version: 6.0.0.beta2
21
21
  type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
25
  - - '='
26
26
  - !ruby/object:Gem::Version
27
- version: 6.0.0.beta1
27
+ version: 6.0.0.beta2
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: nio4r
30
30
  requirement: !ruby/object:Gem::Requirement
@@ -125,8 +125,8 @@ homepage: http://rubyonrails.org
125
125
  licenses:
126
126
  - MIT
127
127
  metadata:
128
- source_code_uri: https://github.com/rails/rails/tree/v6.0.0.beta1/actioncable
129
- changelog_uri: https://github.com/rails/rails/blob/v6.0.0.beta1/actioncable/CHANGELOG.md
128
+ source_code_uri: https://github.com/rails/rails/tree/v6.0.0.beta2/actioncable
129
+ changelog_uri: https://github.com/rails/rails/blob/v6.0.0.beta2/actioncable/CHANGELOG.md
130
130
  post_install_message:
131
131
  rdoc_options: []
132
132
  require_paths: