actioncable 6.0.0.beta1 → 6.0.0.beta2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +69 -0
- data/lib/action_cable/channel/base.rb +2 -0
- data/lib/action_cable/channel/broadcasting.rb +18 -8
- data/lib/action_cable/channel/streams.rb +1 -1
- data/lib/action_cable/channel/test_case.rb +4 -6
- data/lib/action_cable/connection/base.rb +2 -0
- data/lib/action_cable/connection/test_case.rb +0 -2
- data/lib/action_cable/gem_version.rb +1 -1
- data/lib/action_cable/server/base.rb +5 -2
- data/lib/action_cable/subscription_adapter/postgresql.rb +2 -0
- data/lib/rails/generators/channel/templates/javascript/channel.js.tt +3 -3
- data/lib/rails/generators/channel/templates/javascript/consumer.js.tt +2 -2
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d61cfd8a951dcbc35e2450a62475a6dea2dc059ebb51d3d21a648ccd9d818c9c
|
4
|
+
data.tar.gz: 30e24d4dd9dbcfdb6ac4ebbe819a0f0308eeb5eedd727b0c6598bc47effb3453
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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*
|
@@ -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(
|
15
|
+
ActionCable.server.broadcast(broadcasting_for(model), message)
|
16
16
|
end
|
17
17
|
|
18
|
-
|
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
|
21
|
-
|
22
|
-
when
|
23
|
-
|
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
|
-
|
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(
|
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
|
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
|
160
|
+
# subscribe room_id: rooms(:chat).id
|
161
161
|
#
|
162
|
-
# assert_broadcasts_on(rooms
|
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
|
|
@@ -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:
|
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
|
@@ -1,15 +1,15 @@
|
|
1
1
|
import consumer from "./consumer"
|
2
2
|
|
3
3
|
consumer.subscriptions.create("<%= class_name %>Channel", {
|
4
|
-
connected
|
4
|
+
connected() {
|
5
5
|
// Called when the subscription is ready for use on the server
|
6
6
|
},
|
7
7
|
|
8
|
-
disconnected
|
8
|
+
disconnected() {
|
9
9
|
// Called when the subscription has been terminated by the server
|
10
10
|
},
|
11
11
|
|
12
|
-
received
|
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
|
4
|
+
import { createConsumer } from "@rails/actioncable"
|
5
5
|
|
6
|
-
export default
|
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.
|
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-
|
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.
|
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.
|
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.
|
129
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.0.
|
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:
|