actioncable 6.0.0.beta1 → 6.0.1.rc1
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 +4 -4
- data/CHANGELOG.md +94 -0
- data/README.md +1 -1
- data/app/assets/javascripts/action_cable.js +37 -12
- 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 +1 -3
- data/lib/action_cable/gem_version.rb +2 -2
- data/lib/action_cable/server/base.rb +5 -2
- data/lib/action_cable/subscription_adapter/postgresql.rb +2 -0
- data/lib/action_cable/subscription_adapter/redis.rb +3 -1
- 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 +11 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 86d46b846c3fb07e49e3a307349c964e9b11d4c7b06f22a126bbeaa01b158e43
|
|
4
|
+
data.tar.gz: 39167fb170b2d5ea8106427bb3b44cc87079c843e89a96e2bfe6bae489b2370a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e3cf41533f7f14bc919495b240de8f3c6b520f7c4a2dc88ca6190ea7eef7e1ffb578aae6f4089676c3066241b5b0215037a3a89da0c507aa7759018aef002163
|
|
7
|
+
data.tar.gz: 0b674b1b260ba11b94d8a2e5b290659edd3aeff68939b65327f5d494529a5320144ed957428a14f210f10c29bcc263bc475e1595ce2b355b3bd0c29fa67a783f
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,99 @@
|
|
|
1
|
+
## Rails 6.0.1.rc1 (October 31, 2019) ##
|
|
2
|
+
|
|
3
|
+
* No changes.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
## Rails 6.0.0 (August 16, 2019) ##
|
|
7
|
+
|
|
8
|
+
* No changes.
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## Rails 6.0.0.rc2 (July 22, 2019) ##
|
|
12
|
+
|
|
13
|
+
* No changes.
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
## Rails 6.0.0.rc1 (April 24, 2019) ##
|
|
17
|
+
|
|
18
|
+
* No changes.
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
## Rails 6.0.0.beta3 (March 11, 2019) ##
|
|
22
|
+
|
|
23
|
+
* No changes.
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
## Rails 6.0.0.beta2 (February 25, 2019) ##
|
|
27
|
+
|
|
28
|
+
* PostgreSQL subscription adapters now support `channel_prefix` option in cable.yml
|
|
29
|
+
|
|
30
|
+
Avoids channel name collisions when multiple apps use the same database for Action Cable.
|
|
31
|
+
|
|
32
|
+
*Vladimir Dementyev*
|
|
33
|
+
|
|
34
|
+
* Allow passing custom configuration to `ActionCable::Server::Base`.
|
|
35
|
+
|
|
36
|
+
You can now create a standalone Action Cable server with a custom configuration
|
|
37
|
+
(e.g. to run it in isolation from the default one):
|
|
38
|
+
|
|
39
|
+
```ruby
|
|
40
|
+
config = ActionCable::Server::Configuration.new
|
|
41
|
+
config.cable = { adapter: "redis", channel_prefix: "custom_" }
|
|
42
|
+
|
|
43
|
+
CUSTOM_CABLE = ActionCable::Server::Base.new(config: config)
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
Then you can mount it in the `routes.rb` file:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
Rails.application.routes.draw do
|
|
50
|
+
mount CUSTOM_CABLE => "/custom_cable"
|
|
51
|
+
# ...
|
|
52
|
+
end
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
*Vladimir Dementyev*
|
|
56
|
+
|
|
57
|
+
* Add `:action_cable_connection` and `:action_cable_channel` load hooks.
|
|
58
|
+
|
|
59
|
+
You can use them to extend `ActionCable::Connection::Base` and `ActionCable::Channel::Base`
|
|
60
|
+
functionality:
|
|
61
|
+
|
|
62
|
+
```ruby
|
|
63
|
+
ActiveSupport.on_load(:action_cable_channel) do
|
|
64
|
+
# do something in the context of ActionCable::Channel::Base
|
|
65
|
+
end
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
*Vladimir Dementyev*
|
|
69
|
+
|
|
70
|
+
* Add `Channel::Base#broadcast_to`.
|
|
71
|
+
|
|
72
|
+
You can now call `broadcast_to` within a channel action, which equals to
|
|
73
|
+
the `self.class.broadcast_to`.
|
|
74
|
+
|
|
75
|
+
*Vladimir Dementyev*
|
|
76
|
+
|
|
77
|
+
* Make `Channel::Base.broadcasting_for` a public API.
|
|
78
|
+
|
|
79
|
+
You can use `.broadcasting_for` to generate a unique stream identifier within
|
|
80
|
+
a channel for the specified target (e.g. Active Record model):
|
|
81
|
+
|
|
82
|
+
```ruby
|
|
83
|
+
ChatChannel.broadcasting_for(model) # => "chat:<model.to_gid_param>"
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
*Vladimir Dementyev*
|
|
87
|
+
|
|
88
|
+
|
|
1
89
|
## Rails 6.0.0.beta1 (January 18, 2019) ##
|
|
2
90
|
|
|
91
|
+
* [Rename npm package](https://github.com/rails/rails/pull/34905) from
|
|
92
|
+
[`actioncable`](https://www.npmjs.com/package/actioncable) to
|
|
93
|
+
[`@rails/actioncable`](https://www.npmjs.com/package/@rails/actioncable).
|
|
94
|
+
|
|
95
|
+
*Javan Makhmali*
|
|
96
|
+
|
|
3
97
|
* Merge [`action-cable-testing`](https://github.com/palkan/action-cable-testing) to Rails.
|
|
4
98
|
|
|
5
99
|
*Vladimir Dementyev*
|
data/README.md
CHANGED
|
@@ -28,6 +28,22 @@
|
|
|
28
28
|
throw new TypeError("Cannot call a class as a function");
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
|
+
var createClass = function() {
|
|
32
|
+
function defineProperties(target, props) {
|
|
33
|
+
for (var i = 0; i < props.length; i++) {
|
|
34
|
+
var descriptor = props[i];
|
|
35
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
36
|
+
descriptor.configurable = true;
|
|
37
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
38
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return function(Constructor, protoProps, staticProps) {
|
|
42
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
43
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
44
|
+
return Constructor;
|
|
45
|
+
};
|
|
46
|
+
}();
|
|
31
47
|
var now = function now() {
|
|
32
48
|
return new Date().getTime();
|
|
33
49
|
};
|
|
@@ -432,7 +448,7 @@
|
|
|
432
448
|
var Consumer = function() {
|
|
433
449
|
function Consumer(url) {
|
|
434
450
|
classCallCheck(this, Consumer);
|
|
435
|
-
this.
|
|
451
|
+
this._url = url;
|
|
436
452
|
this.subscriptions = new Subscriptions(this);
|
|
437
453
|
this.connection = new Connection(this);
|
|
438
454
|
}
|
|
@@ -452,19 +468,18 @@
|
|
|
452
468
|
return this.connection.open();
|
|
453
469
|
}
|
|
454
470
|
};
|
|
471
|
+
createClass(Consumer, [ {
|
|
472
|
+
key: "url",
|
|
473
|
+
get: function get$$1() {
|
|
474
|
+
return createWebSocketURL(this._url);
|
|
475
|
+
}
|
|
476
|
+
} ]);
|
|
455
477
|
return Consumer;
|
|
456
478
|
}();
|
|
457
|
-
function createConsumer() {
|
|
458
|
-
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getConfig("url") || INTERNAL.default_mount_path;
|
|
459
|
-
return new Consumer(createWebSocketURL(url));
|
|
460
|
-
}
|
|
461
|
-
function getConfig(name) {
|
|
462
|
-
var element = document.head.querySelector("meta[name='action-cable-" + name + "']");
|
|
463
|
-
if (element) {
|
|
464
|
-
return element.getAttribute("content");
|
|
465
|
-
}
|
|
466
|
-
}
|
|
467
479
|
function createWebSocketURL(url) {
|
|
480
|
+
if (typeof url === "function") {
|
|
481
|
+
url = url();
|
|
482
|
+
}
|
|
468
483
|
if (url && !/^wss?:/i.test(url)) {
|
|
469
484
|
var a = document.createElement("a");
|
|
470
485
|
a.href = url;
|
|
@@ -475,6 +490,16 @@
|
|
|
475
490
|
return url;
|
|
476
491
|
}
|
|
477
492
|
}
|
|
493
|
+
function createConsumer() {
|
|
494
|
+
var url = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : getConfig("url") || INTERNAL.default_mount_path;
|
|
495
|
+
return new Consumer(url);
|
|
496
|
+
}
|
|
497
|
+
function getConfig(name) {
|
|
498
|
+
var element = document.head.querySelector("meta[name='action-cable-" + name + "']");
|
|
499
|
+
if (element) {
|
|
500
|
+
return element.getAttribute("content");
|
|
501
|
+
}
|
|
502
|
+
}
|
|
478
503
|
exports.Connection = Connection;
|
|
479
504
|
exports.ConnectionMonitor = ConnectionMonitor;
|
|
480
505
|
exports.Consumer = Consumer;
|
|
@@ -482,10 +507,10 @@
|
|
|
482
507
|
exports.Subscription = Subscription;
|
|
483
508
|
exports.Subscriptions = Subscriptions;
|
|
484
509
|
exports.adapters = adapters;
|
|
510
|
+
exports.createWebSocketURL = createWebSocketURL;
|
|
485
511
|
exports.logger = logger;
|
|
486
512
|
exports.createConsumer = createConsumer;
|
|
487
513
|
exports.getConfig = getConfig;
|
|
488
|
-
exports.createWebSocketURL = createWebSocketURL;
|
|
489
514
|
Object.defineProperty(exports, "__esModule", {
|
|
490
515
|
value: true
|
|
491
516
|
});
|
|
@@ -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
|
|
|
@@ -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
|
|
@@ -178,7 +176,7 @@ module ActionCable
|
|
|
178
176
|
#
|
|
179
177
|
# Accepts request path as the first argument and the following request options:
|
|
180
178
|
#
|
|
181
|
-
# - params –
|
|
179
|
+
# - params – URL parameters (Hash)
|
|
182
180
|
# - headers – request headers (Hash)
|
|
183
181
|
# - session – session data (Hash)
|
|
184
182
|
# - env – additional Rack env configuration (Hash)
|
|
@@ -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
|
|
@@ -5,6 +5,8 @@ require "thread"
|
|
|
5
5
|
gem "redis", ">= 3", "< 5"
|
|
6
6
|
require "redis"
|
|
7
7
|
|
|
8
|
+
require "active_support/core_ext/hash/except"
|
|
9
|
+
|
|
8
10
|
module ActionCable
|
|
9
11
|
module SubscriptionAdapter
|
|
10
12
|
class Redis < Base # :nodoc:
|
|
@@ -14,7 +16,7 @@ module ActionCable
|
|
|
14
16
|
# This is needed, for example, when using Makara proxies for distributed Redis.
|
|
15
17
|
cattr_accessor :redis_connector, default: ->(config) do
|
|
16
18
|
config[:id] ||= "ActionCable-PID-#{$$}"
|
|
17
|
-
::Redis.new(config.
|
|
19
|
+
::Redis.new(config.except(:adapter, :channel_prefix))
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def initialize(*)
|
|
@@ -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.
|
|
4
|
+
version: 6.0.1.rc1
|
|
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-10-31 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.
|
|
20
|
+
version: 6.0.1.rc1
|
|
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.
|
|
27
|
+
version: 6.0.1.rc1
|
|
28
28
|
- !ruby/object:Gem::Dependency
|
|
29
29
|
name: nio4r
|
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -121,12 +121,15 @@ files:
|
|
|
121
121
|
- lib/rails/generators/channel/templates/javascript/index.js.tt
|
|
122
122
|
- lib/rails/generators/test_unit/channel_generator.rb
|
|
123
123
|
- lib/rails/generators/test_unit/templates/channel_test.rb.tt
|
|
124
|
-
homepage:
|
|
124
|
+
homepage: https://rubyonrails.org
|
|
125
125
|
licenses:
|
|
126
126
|
- MIT
|
|
127
127
|
metadata:
|
|
128
|
-
|
|
129
|
-
changelog_uri: https://github.com/rails/rails/blob/v6.0.
|
|
128
|
+
bug_tracker_uri: https://github.com/rails/rails/issues
|
|
129
|
+
changelog_uri: https://github.com/rails/rails/blob/v6.0.1.rc1/actioncable/CHANGELOG.md
|
|
130
|
+
documentation_uri: https://api.rubyonrails.org/v6.0.1.rc1/
|
|
131
|
+
mailing_list_uri: https://groups.google.com/forum/#!forum/rubyonrails-talk
|
|
132
|
+
source_code_uri: https://github.com/rails/rails/tree/v6.0.1.rc1/actioncable
|
|
130
133
|
post_install_message:
|
|
131
134
|
rdoc_options: []
|
|
132
135
|
require_paths:
|
|
@@ -142,7 +145,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
142
145
|
- !ruby/object:Gem::Version
|
|
143
146
|
version: 1.3.1
|
|
144
147
|
requirements: []
|
|
145
|
-
rubygems_version: 3.0.
|
|
148
|
+
rubygems_version: 3.0.3
|
|
146
149
|
signing_key:
|
|
147
150
|
specification_version: 4
|
|
148
151
|
summary: WebSocket framework for Rails.
|