actioncable-next 0.3.2 → 0.3.3

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: 4218440a66ebe42d3a2f0e3acddb8ee929308296e9bef6b7efe6028e1ea00c89
4
- data.tar.gz: 4474877342a6bb7520ca7b114aed1f0fec551bb2df5d0041bbf445fca3372775
3
+ metadata.gz: 1b36ee2ec9c46a0f394fd64434e75a297ee3b4f69a16b8b319e118ee8055f7d6
4
+ data.tar.gz: dc02ca5891bc93571147fe8ef4048ec6ec6830537d0d7c68d7a774a7a533383a
5
5
  SHA512:
6
- metadata.gz: 22bf0972d72b0b016b620b748c6d5b7aa783e7ad298786c2da92aa47e3af704b5e14aab94c0267375c7a26554dc166e41bc8c47de8b127d32657b3c7b9652a7c
7
- data.tar.gz: f908764444fb87f16f9d52e693325bfb52469cfec7ef16484f95d984227591b65908b5b1cdafb4fef9818653f4abede75e54567a2d41f6b80e0d6919a09343a2
6
+ metadata.gz: 81ba40123c990cf98379327e4119a3ff9cdb6cb85306d196764bf03a6bc9df5a0361203cb45c8cd60296c37dde66b318f4557d996d1dcbdc7de312ffc70d74c5
7
+ data.tar.gz: e25aa2cccda9fdb63cc96235a0f92bc2b8ce0e00202ae3170855363c2de3547c874eba8779b05b58e91c63edefbd6fe3aadd6302494ec1aa49ac936f1f139877
data/CHANGELOG.md CHANGED
@@ -2,6 +2,10 @@
2
2
 
3
3
  ## main
4
4
 
5
+ ## 0.3.3
6
+
7
+ - Sync with upstream (Rails 8.2.0.alpha).
8
+
5
9
  ## 0.3.2
6
10
 
7
11
  - Add `#advance_time` test helper to channels to test periodic timers.
@@ -135,6 +135,7 @@ module ActionCable
135
135
  public_instance_methods(false) -
136
136
  # Except the internal methods
137
137
  internal_methods).uniq
138
+
138
139
  methods.map!(&:name)
139
140
  methods.to_set
140
141
  end
@@ -148,15 +149,15 @@ module ActionCable
148
149
  @action_methods = nil
149
150
  end
150
151
 
151
- def internal_methods
152
- super
153
- end
154
-
155
152
  # Refresh the cached action_methods when a new action_method is added.
156
153
  def method_added(name) # :doc:
157
154
  super
158
155
  clear_action_methods!
159
156
  end
157
+
158
+ def internal_methods
159
+ super
160
+ end
160
161
  end
161
162
 
162
163
  def initialize(connection, identifier, params = {})
@@ -39,7 +39,7 @@ module ActionCable
39
39
  extend ActiveSupport::Concern
40
40
  include ActiveSupport::Callbacks
41
41
 
42
- INTERNAL_METHODS = [:_run_subscribe_callbacks, :_run_unsubscribe_callbacks] # :nodoc:
42
+ INTERNAL_METHODS = [:_run_subscribe_callbacks, :_run_unsubscribe_callbacks].freeze # :nodoc:
43
43
 
44
44
  included do
45
45
  define_callbacks :subscribe
@@ -4,6 +4,12 @@
4
4
 
5
5
  require "active_support/rescuable"
6
6
 
7
+ begin
8
+ require "active_support/inspect_backport"
9
+ rescue LoadError
10
+ # ActiveSupport::InspectBackport ships only in Rails 8.2+; older Rails keeps the gem's custom #inspect.
11
+ end
12
+
7
13
  module ActionCable
8
14
  module Connection
9
15
  # # Action Cable Connection Base
@@ -147,11 +153,19 @@ module ActionCable
147
153
  transmit type: ActionCable::INTERNAL[:message_types][:ping], message: Time.now.to_i
148
154
  end
149
155
 
150
- def inspect # :nodoc:
151
- "#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
156
+ if defined?(ActiveSupport::InspectBackport)
157
+ ActiveSupport::InspectBackport.apply(self)
158
+ else
159
+ def inspect # :nodoc:
160
+ "#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
161
+ end
152
162
  end
153
163
 
154
164
  private
165
+ def instance_variables_to_inspect # :nodoc:
166
+ [].freeze
167
+ end
168
+
155
169
  # The cookies of the request that initiated the WebSocket connection. Useful for performing authorization checks.
156
170
  def cookies # :doc:
157
171
  request.cookie_jar
@@ -12,6 +12,13 @@ module ActionCable
12
12
  config.action_cable.mount_path = ActionCable::INTERNAL[:default_mount_path]
13
13
  config.action_cable.precompile_assets = true
14
14
 
15
+ if respond_to?(:guard_load_hooks)
16
+ guard_load_hooks(
17
+ :action_cable_channel, :action_cable_connection,
18
+ :action_cable_test_case, :action_cable_connection_test_case,
19
+ )
20
+ end
21
+
15
22
  initializer "action_cable.deprecator", before: :load_environment_config do |app|
16
23
  app.deprecators[:action_cable] = ActionCable.deprecator
17
24
  end
@@ -83,15 +90,17 @@ module ActionCable
83
90
  end
84
91
  end
85
92
 
93
+ app.reloader.before_class_unload do
94
+ ActionCable.server.restart
95
+ end
96
+ end
97
+
98
+ ActiveSupport.on_load(:action_cable_channel) do
86
99
  wrap = lambda do |_, inner|
87
100
  app.executor.wrap(source: "application.action_cable", &inner)
88
101
  end
89
102
  ActionCable::Channel::Base.set_callback :subscribe, :around, prepend: true, &wrap
90
103
  ActionCable::Channel::Base.set_callback :unsubscribe, :around, prepend: true, &wrap
91
-
92
- app.reloader.before_class_unload do
93
- ActionCable.server.restart
94
- end
95
104
  end
96
105
  end
97
106
 
@@ -8,9 +8,9 @@ module ActionCable
8
8
  module Server
9
9
  # A wrapper over ConcurrentRuby::ThreadPoolExecutor and Concurrent::TimerTask
10
10
  class ThreadedExecutor # :nodoc:
11
- def initialize(max_size: 10)
11
+ def initialize(max_size: 10, name: "server")
12
12
  @executor = Concurrent::ThreadPoolExecutor.new(
13
- name: "ActionCable-streamer",
13
+ name: "ActionCable-#{name}",
14
14
  min_threads: 1,
15
15
  max_threads: max_size,
16
16
  max_queue: 0,
@@ -121,7 +121,7 @@ module ActionCable
121
121
 
122
122
  # Executor is used by various actions within Action Cable (e.g., pub/sub operations) to run code asynchronously.
123
123
  def executor
124
- @executor || @mutex.synchronize { @executor ||= ThreadedExecutor.new(max_size: config.executor_pool_size) }
124
+ @executor || @mutex.synchronize { @executor ||= ThreadedExecutor.new(max_size: config.executor_pool_size, name: "streamer") }
125
125
  end
126
126
 
127
127
  # Adapter used for all streams/broadcasting.
@@ -146,8 +146,9 @@ module ActionCable
146
146
  def allow_request_origin?(env)
147
147
  return true if config.disable_request_forgery_protection
148
148
 
149
- proto = Rack::Request.new(env).ssl? ? "https" : "http"
150
- if config.allow_same_origin_as_host && env["HTTP_ORIGIN"] == "#{proto}://#{env['HTTP_HOST']}"
149
+ request = ActionDispatch::Request.new(env)
150
+ proto = request.ssl? ? "https" : "http"
151
+ if config.allow_same_origin_as_host && env["HTTP_ORIGIN"] == "#{proto}://#{request.host_with_port}"
151
152
  true
152
153
  elsif Array(config.allowed_request_origins).any? { |allowed_origin| allowed_origin === env["HTTP_ORIGIN"] }
153
154
  true
@@ -21,12 +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 JavaScript, which assumes you've already requested the right to send web notifications:
24
+ # # Client-side JavaScript, which assumes you've already requested the right to send web notifications:
25
25
  # App.cable.subscriptions.create("WebNotificationsChannel", {
26
26
  # received: function(data) {
27
- # new Notification(data['title'], { body: data['body'] });
27
+ # new Notification(data['title'], { body: data['body'] })
28
28
  # }
29
- # });
29
+ # })
30
30
  module Broadcasting
31
31
  # Broadcast a hash directly to a named `broadcasting`. This will later be JSON
32
32
  # encoded.
@@ -2,6 +2,12 @@
2
2
 
3
3
  require "action_dispatch"
4
4
 
5
+ begin
6
+ require "active_support/inspect_backport"
7
+ rescue LoadError
8
+ # ActiveSupport::InspectBackport ships only in Rails 8.2+; older Rails keeps the gem's custom #inspect.
9
+ end
10
+
5
11
  module ActionCable
6
12
  module Server
7
13
  # This class encapsulates all the low-level logic of working with the underlying WebSocket conenctions
@@ -108,11 +114,19 @@ module ActionCable
108
114
  send_async :handle_close
109
115
  end
110
116
 
111
- def inspect # :nodoc:
112
- "#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
117
+ if defined?(ActiveSupport::InspectBackport)
118
+ ActiveSupport::InspectBackport.apply(self)
119
+ else
120
+ def inspect # :nodoc:
121
+ "#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
122
+ end
113
123
  end
114
124
 
115
125
  private
126
+ def instance_variables_to_inspect # :nodoc:
127
+ [].freeze
128
+ end
129
+
116
130
  attr_reader :websocket
117
131
  attr_reader :message_buffer
118
132
 
@@ -38,7 +38,7 @@ module ActionCable
38
38
  def with_subscriptions_connection(&block) # :nodoc:
39
39
  # Action Cable is taking ownership over this database connection, and will
40
40
  # perform the necessary cleanup tasks.
41
- # We purposedly avoid #checkout to not end up with a pinned connection
41
+ # We purposely avoid #checkout to not end up with a pinned connection
42
42
  ar_conn = ActiveRecord::Base.connection_pool.new_connection
43
43
  pg_conn = ar_conn.raw_connection
44
44
 
data/lib/action_cable.rb CHANGED
@@ -74,7 +74,7 @@ module ActionCable
74
74
  },
75
75
  default_mount_path: "/cable",
76
76
  protocols: ["actioncable-v1-json", "actioncable-unsupported"].freeze
77
- }
77
+ }.freeze
78
78
 
79
79
  # Singleton instance of the server
80
80
  module_function def server
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ActionCableNext
4
- VERSION = "0.3.2"
4
+ VERSION = "0.3.3"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actioncable-next
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pratik Naik
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2026-04-30 00:00:00.000000000 Z
13
+ date: 2026-05-20 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activesupport
@@ -167,7 +167,7 @@ licenses:
167
167
  - MIT
168
168
  metadata:
169
169
  bug_tracker_uri: https://github.com/anycable/actioncable-next
170
- changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.3.2/CHANGELOG.md
170
+ changelog_uri: https://github.com/anycable/actioncable-next/blob/v0.3.3/CHANGELOG.md
171
171
  source_code_uri: https://github.com/anycable/actioncable-next
172
172
  rubygems_mfa_required: 'true'
173
173
  post_install_message: