actioncable 8.0.2 → 8.1.0.beta1
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 +6 -42
- data/README.md +1 -1
- data/lib/action_cable/channel/base.rb +6 -0
- data/lib/action_cable/channel/broadcasting.rb +6 -6
- data/lib/action_cable/channel/streams.rb +5 -3
- data/lib/action_cable/connection/stream_event_loop.rb +1 -0
- data/lib/action_cable/gem_version.rb +3 -3
- data/lib/action_cable/server/broadcasting.rb +6 -4
- data/lib/action_cable/server/worker.rb +1 -1
- data/lib/action_cable/subscription_adapter/base.rb +2 -1
- data/lib/action_cable/subscription_adapter/redis.rb +8 -3
- data/lib/rails/generators/channel/channel_generator.rb +4 -4
- metadata +10 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 23d628c9902e296471a081c1fd0781d562485649067e725dd85f2d13aeb1ab77
|
4
|
+
data.tar.gz: ad44df73a5681b4ecaeeee4d4831107da2da833210c78e9f86ad1bf11195d920
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1197007dc525dbdaece760efafe54b6b5bf7eb4c30f37b4b899aeaf0e0bbf8fe7598b9c391ca0efa2f0b9f4f70703cce154126f09b151e2bbbac0a5c62ee75e1
|
7
|
+
data.tar.gz: 41338ae8f3611fffe437dc6a9f1f215bc1e03b8a0515ad7feaed8a28db96a67d5c7454b845b8e9637a2d61ba2d2aa7143fa3918feaaa9629b167fd63ee6719b0
|
data/CHANGELOG.md
CHANGED
@@ -1,47 +1,11 @@
|
|
1
|
-
## Rails 8.0.
|
1
|
+
## Rails 8.1.0.beta1 (September 04, 2025) ##
|
2
2
|
|
3
|
-
*
|
3
|
+
* Allow passing composite channels to `ActionCable::Channel#stream_for` – e.g. `stream_for [ group, group.owner ]`
|
4
4
|
|
5
|
+
*hey-leon*
|
5
6
|
|
6
|
-
|
7
|
+
* Allow setting nil as subscription connection identifier for Redis.
|
7
8
|
|
8
|
-
*
|
9
|
+
*Nguyen Nguyen*
|
9
10
|
|
10
|
-
|
11
|
-
## Rails 8.0.1 (December 13, 2024) ##
|
12
|
-
|
13
|
-
* Ensure the Postgresql adapter always use a dedicated connection even during system tests.
|
14
|
-
|
15
|
-
Fix an issue with the Action Cable Postgresql adapter causing deadlock or various weird
|
16
|
-
pg client error during system tests.
|
17
|
-
|
18
|
-
*Jean Boussier*
|
19
|
-
|
20
|
-
|
21
|
-
## Rails 8.0.0.1 (December 10, 2024) ##
|
22
|
-
|
23
|
-
* No changes.
|
24
|
-
|
25
|
-
|
26
|
-
## Rails 8.0.0 (November 07, 2024) ##
|
27
|
-
|
28
|
-
* No changes.
|
29
|
-
|
30
|
-
|
31
|
-
## Rails 8.0.0.rc2 (October 30, 2024) ##
|
32
|
-
|
33
|
-
* No changes.
|
34
|
-
|
35
|
-
|
36
|
-
## Rails 8.0.0.rc1 (October 19, 2024) ##
|
37
|
-
|
38
|
-
* No changes.
|
39
|
-
|
40
|
-
|
41
|
-
## Rails 8.0.0.beta1 (September 26, 2024) ##
|
42
|
-
|
43
|
-
* Add an `identifier` to the event payload for the ActiveSupport::Notification `transmit_subscription_confirmation.action_cable` and `transmit_subscription_rejection.action_cable`.
|
44
|
-
|
45
|
-
*Keith Schacht*
|
46
|
-
|
47
|
-
Please check [7-2-stable](https://github.com/rails/rails/blob/7-2-stable/actioncable/CHANGELOG.md) for previous changes.
|
11
|
+
Please check [8-0-stable](https://github.com/rails/rails/blob/8-0-stable/actioncable/CHANGELOG.md) for previous changes.
|
data/README.md
CHANGED
@@ -19,6 +19,6 @@ Bug reports for the Ruby on \Rails project can be filed here:
|
|
19
19
|
|
20
20
|
* https://github.com/rails/rails/issues
|
21
21
|
|
22
|
-
Feature requests should be discussed on the
|
22
|
+
Feature requests should be discussed on the rubyonrails-core forum here:
|
23
23
|
|
24
24
|
* https://discuss.rubyonrails.org/c/rubyonrails-core
|
@@ -165,6 +165,7 @@ module ActionCable
|
|
165
165
|
|
166
166
|
@reject_subscription = nil
|
167
167
|
@subscription_confirmation_sent = nil
|
168
|
+
@unsubscribed = false
|
168
169
|
|
169
170
|
delegate_connection_identifiers
|
170
171
|
end
|
@@ -200,11 +201,16 @@ module ActionCable
|
|
200
201
|
# cleanup with callbacks. This method is not intended to be called directly by
|
201
202
|
# the user. Instead, override the #unsubscribed callback.
|
202
203
|
def unsubscribe_from_channel # :nodoc:
|
204
|
+
@unsubscribed = true
|
203
205
|
run_callbacks :unsubscribe do
|
204
206
|
unsubscribed
|
205
207
|
end
|
206
208
|
end
|
207
209
|
|
210
|
+
def unsubscribed? # :nodoc:
|
211
|
+
@unsubscribed
|
212
|
+
end
|
213
|
+
|
208
214
|
private
|
209
215
|
# Called once a consumer has become a subscriber of the channel. Usually the
|
210
216
|
# place to set up any streams you want this channel to be sending to the
|
@@ -10,19 +10,19 @@ module ActionCable
|
|
10
10
|
extend ActiveSupport::Concern
|
11
11
|
|
12
12
|
module ClassMethods
|
13
|
-
# Broadcast a hash to a unique broadcasting for this `
|
14
|
-
def broadcast_to(
|
15
|
-
ActionCable.server.broadcast(broadcasting_for(
|
13
|
+
# Broadcast a hash to a unique broadcasting for this array of `broadcastables` in this channel.
|
14
|
+
def broadcast_to(broadcastables, message)
|
15
|
+
ActionCable.server.broadcast(broadcasting_for(broadcastables), message)
|
16
16
|
end
|
17
17
|
|
18
18
|
# Returns a unique broadcasting identifier for this `model` in this channel:
|
19
19
|
#
|
20
20
|
# CommentsChannel.broadcasting_for("all") # => "comments:all"
|
21
21
|
#
|
22
|
-
# You can pass
|
22
|
+
# You can pass an array of objects as a target (e.g. Active Record model), and it would
|
23
23
|
# be serialized into a string under the hood.
|
24
|
-
def broadcasting_for(
|
25
|
-
serialize_broadcasting([ channel_name
|
24
|
+
def broadcasting_for(broadcastables)
|
25
|
+
serialize_broadcasting([ channel_name ] + Array(broadcastables))
|
26
26
|
end
|
27
27
|
|
28
28
|
private
|
@@ -88,6 +88,8 @@ module ActionCable
|
|
88
88
|
# callback. Defaults to `coder: nil` which does no decoding, passes raw
|
89
89
|
# messages.
|
90
90
|
def stream_from(broadcasting, callback = nil, coder: nil, &block)
|
91
|
+
return if unsubscribed?
|
92
|
+
|
91
93
|
broadcasting = String(broadcasting)
|
92
94
|
|
93
95
|
# Don't send the confirmation until pubsub#subscribe is successful
|
@@ -106,15 +108,15 @@ module ActionCable
|
|
106
108
|
end
|
107
109
|
end
|
108
110
|
|
109
|
-
# Start streaming the pubsub queue for the `
|
111
|
+
# Start streaming the pubsub queue for the `broadcastables` in this channel. Optionally,
|
110
112
|
# you can pass a `callback` that'll be used instead of the default of just
|
111
113
|
# transmitting the updates straight to the subscriber.
|
112
114
|
#
|
113
115
|
# Pass `coder: ActiveSupport::JSON` to decode messages as JSON before passing to
|
114
116
|
# the callback. Defaults to `coder: nil` which does no decoding, passes raw
|
115
117
|
# messages.
|
116
|
-
def stream_for(
|
117
|
-
stream_from(broadcasting_for(
|
118
|
+
def stream_for(broadcastables, callback = nil, coder: nil, &block)
|
119
|
+
stream_from(broadcasting_for(broadcastables), callback || block, coder: coder)
|
118
120
|
end
|
119
121
|
|
120
122
|
# Unsubscribes streams from the named `broadcasting`.
|
@@ -21,10 +21,12 @@ module ActionCable
|
|
21
21
|
# ActionCable.server.broadcast \
|
22
22
|
# "web_notifications_1", { title: "New things!", body: "All that's fit for print" }
|
23
23
|
#
|
24
|
-
# # Client-side
|
25
|
-
# App.cable.subscriptions.create
|
26
|
-
# received: (data)
|
27
|
-
# new Notification
|
24
|
+
# # Client-side JavaScript, which assumes you've already requested the right to send web notifications:
|
25
|
+
# App.cable.subscriptions.create("WebNotificationsChannel", {
|
26
|
+
# received: function(data) {
|
27
|
+
# new Notification(data['title'], { body: data['body'] })
|
28
|
+
# }
|
29
|
+
# })
|
28
30
|
module Broadcasting
|
29
31
|
# Broadcast a hash directly to a named `broadcasting`. This will later be JSON
|
30
32
|
# encoded.
|
@@ -164,7 +164,7 @@ module ActionCable
|
|
164
164
|
begin
|
165
165
|
conn = @adapter.redis_connection_for_subscriptions
|
166
166
|
listen conn
|
167
|
-
rescue
|
167
|
+
rescue *CONNECTION_ERRORS
|
168
168
|
reset
|
169
169
|
if retry_connecting?
|
170
170
|
when_connected { resubscribe }
|
@@ -210,7 +210,7 @@ module ActionCable
|
|
210
210
|
end
|
211
211
|
|
212
212
|
if ::Redis::VERSION < "5"
|
213
|
-
|
213
|
+
CONNECTION_ERRORS = [::Redis::BaseConnectionError].freeze
|
214
214
|
|
215
215
|
class SubscribedClient
|
216
216
|
def initialize(raw_client)
|
@@ -244,7 +244,12 @@ module ActionCable
|
|
244
244
|
SubscribedClient.new(conn._client)
|
245
245
|
end
|
246
246
|
else
|
247
|
-
|
247
|
+
CONNECTION_ERRORS = [
|
248
|
+
::Redis::BaseConnectionError,
|
249
|
+
|
250
|
+
# Some older versions of redis-rb sometime leak underlying exceptions
|
251
|
+
RedisClient::ConnectionError,
|
252
|
+
].freeze
|
248
253
|
|
249
254
|
def extract_subscribed_client(conn)
|
250
255
|
conn
|
@@ -59,17 +59,17 @@ module Rails
|
|
59
59
|
def create_channel_javascript_file
|
60
60
|
channel_js_path = File.join("app/javascript/channels", class_path, "#{file_name}_channel")
|
61
61
|
js_template "javascript/channel", channel_js_path
|
62
|
-
gsub_file "#{channel_js_path}.js", /\.\/consumer/, "channels/consumer"
|
62
|
+
gsub_file "#{channel_js_path}.js", /\.\/consumer/, "channels/consumer" if using_importmap?
|
63
63
|
end
|
64
64
|
|
65
65
|
def import_channels_in_javascript_entrypoint
|
66
66
|
append_to_file "app/javascript/application.js",
|
67
|
-
|
67
|
+
using_importmap? ? %(import "channels"\n) : %(import "./channels"\n)
|
68
68
|
end
|
69
69
|
|
70
70
|
def import_channel_in_javascript_entrypoint
|
71
71
|
append_to_file "app/javascript/channels/index.js",
|
72
|
-
|
72
|
+
using_importmap? ? %(import "channels/#{file_name}_channel"\n) : %(import "./#{file_name}_channel"\n)
|
73
73
|
end
|
74
74
|
|
75
75
|
def install_javascript_dependencies
|
@@ -105,7 +105,7 @@ pin_all_from "app/javascript/channels", under: "channels"
|
|
105
105
|
end
|
106
106
|
|
107
107
|
def using_bun?
|
108
|
-
# Cannot assume
|
108
|
+
# Cannot assume Bun lockfile has been generated yet so we look for a file known to
|
109
109
|
# be generated by the jsbundling-rails gem
|
110
110
|
@using_bun ||= using_js_runtime? && root.join("bun.config.js").exist?
|
111
111
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actioncable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 8.0.
|
4
|
+
version: 8.1.0.beta1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pratik Naik
|
8
8
|
- David Heinemeier Hansson
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -16,28 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - '='
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 8.0.
|
19
|
+
version: 8.1.0.beta1
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - '='
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 8.0.
|
26
|
+
version: 8.1.0.beta1
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: actionpack
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
31
|
- - '='
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: 8.0.
|
33
|
+
version: 8.1.0.beta1
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: 8.0.
|
40
|
+
version: 8.1.0.beta1
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: nio4r
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -153,10 +153,10 @@ licenses:
|
|
153
153
|
- MIT
|
154
154
|
metadata:
|
155
155
|
bug_tracker_uri: https://github.com/rails/rails/issues
|
156
|
-
changelog_uri: https://github.com/rails/rails/blob/v8.0.
|
157
|
-
documentation_uri: https://api.rubyonrails.org/v8.0.
|
156
|
+
changelog_uri: https://github.com/rails/rails/blob/v8.1.0.beta1/actioncable/CHANGELOG.md
|
157
|
+
documentation_uri: https://api.rubyonrails.org/v8.1.0.beta1/
|
158
158
|
mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
|
159
|
-
source_code_uri: https://github.com/rails/rails/tree/v8.0.
|
159
|
+
source_code_uri: https://github.com/rails/rails/tree/v8.1.0.beta1/actioncable
|
160
160
|
rubygems_mfa_required: 'true'
|
161
161
|
rdoc_options: []
|
162
162
|
require_paths:
|
@@ -172,7 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
172
172
|
- !ruby/object:Gem::Version
|
173
173
|
version: '0'
|
174
174
|
requirements: []
|
175
|
-
rubygems_version: 3.6.
|
175
|
+
rubygems_version: 3.6.9
|
176
176
|
specification_version: 4
|
177
177
|
summary: WebSocket framework for Rails.
|
178
178
|
test_files: []
|