actioncable 7.0.3.1 → 7.0.4

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: 408aec7614b5d7b932c1d3b56c3f94c6b88702586571742865c9950b81be78da
4
- data.tar.gz: 36de66d136571f0a41aaa1aaf15e83815ecf6e3a2240a5a9aab82a99367db677
3
+ metadata.gz: 51532672c5293e1ac4ffdf854f4ee41de231ef843e6ddbc51a20fdede0e029e5
4
+ data.tar.gz: f5324ae765aa6bcdc65590be2f2ad0c034e9b1a58d318a4f27e9e9f7e6ffd3c1
5
5
  SHA512:
6
- metadata.gz: 7034514598796cdec586ba1b822aaaa2a73239ce13c85b5dba63e0407c5b543dd9649d19678c11d179a8704303f2a49fdc40d8a55c3b7489fb7cafa845d92dd0
7
- data.tar.gz: d6bd2c02af39ceea3bd37c6a737293d87a373ca7bb3ea28f6462ea1d8099521f8d5ea2b002cc21fe66278fdab59b3368afdc81b8a2d69b0060b1fd463a2dbb3a
6
+ metadata.gz: 6084037b957593e0e31cdf7c55030f9f2921d03a93b01f0bdb54f2460936909667350edba98b10e287a3563bd39231606abf1f575f45ee47b603d748ef48a072
7
+ data.tar.gz: c2457611b9b2694955a9613fc27211e34e4d7b4b0d98b084eca9e1b0052f6ccbbfdacd0133d6b0da2eb1bed895c7a18bfe32ae5dfac167c4725bb8b45dcd6bf9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,18 @@
1
+ ## Rails 7.0.4 (September 09, 2022) ##
2
+
3
+ * The Redis adapter is now compatible with redis-rb 5.0
4
+
5
+ Compatibility with redis-rb 3.x was dropped.
6
+
7
+ *Jean Boussier*
8
+
9
+ * The Action Cable server is now mounted with `anchor: true`.
10
+
11
+ This means that routes that also start with `/cable` will no longer clash with Action Cable.
12
+
13
+ *Alex Ghiculescu*
14
+
15
+
1
16
  ## Rails 7.0.3.1 (July 12, 2022) ##
2
17
 
3
18
  * No changes.
@@ -54,7 +54,7 @@ module ActionCable
54
54
  config = app.config
55
55
  unless config.action_cable.mount_path.nil?
56
56
  app.routes.prepend do
57
- mount ActionCable.server => config.action_cable.mount_path, internal: true
57
+ mount ActionCable.server => config.action_cable.mount_path, internal: true, anchor: true
58
58
  end
59
59
  end
60
60
  end
@@ -9,8 +9,8 @@ module ActionCable
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 3
13
- PRE = "1"
12
+ TINY = 4
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  require "thread"
4
4
 
5
- gem "redis", ">= 3", "< 5"
5
+ gem "redis", ">= 3", "< 6"
6
6
  require "redis"
7
7
 
8
8
  require "active_support/core_ext/hash/except"
@@ -56,7 +56,7 @@ module ActionCable
56
56
  end
57
57
 
58
58
  def redis_connection
59
- self.class.redis_connector.call(@server.config.cable.merge(id: identifier))
59
+ self.class.redis_connector.call(@server.config.cable.symbolize_keys.merge(id: identifier))
60
60
  end
61
61
 
62
62
  class Listener < SubscriberMap
@@ -69,7 +69,7 @@ module ActionCable
69
69
  @subscribe_callbacks = Hash.new { |h, k| h[k] = [] }
70
70
  @subscription_lock = Mutex.new
71
71
 
72
- @raw_client = nil
72
+ @subscribed_client = nil
73
73
 
74
74
  @when_connected = []
75
75
 
@@ -78,13 +78,13 @@ module ActionCable
78
78
 
79
79
  def listen(conn)
80
80
  conn.without_reconnect do
81
- original_client = conn.respond_to?(:_client) ? conn._client : conn.client
81
+ original_client = extract_subscribed_client(conn)
82
82
 
83
83
  conn.subscribe("_action_cable_internal") do |on|
84
84
  on.subscribe do |chan, count|
85
85
  @subscription_lock.synchronize do
86
86
  if count == 1
87
- @raw_client = original_client
87
+ @subscribed_client = original_client
88
88
 
89
89
  until @when_connected.empty?
90
90
  @when_connected.shift.call
@@ -106,7 +106,7 @@ module ActionCable
106
106
  on.unsubscribe do |chan, count|
107
107
  if count == 0
108
108
  @subscription_lock.synchronize do
109
- @raw_client = nil
109
+ @subscribed_client = nil
110
110
  end
111
111
  end
112
112
  end
@@ -119,8 +119,8 @@ module ActionCable
119
119
  return if @thread.nil?
120
120
 
121
121
  when_connected do
122
- send_command("unsubscribe")
123
- @raw_client = nil
122
+ @subscribed_client.unsubscribe
123
+ @subscribed_client = nil
124
124
  end
125
125
  end
126
126
 
@@ -131,13 +131,13 @@ module ActionCable
131
131
  @subscription_lock.synchronize do
132
132
  ensure_listener_running
133
133
  @subscribe_callbacks[channel] << on_success
134
- when_connected { send_command("subscribe", channel) }
134
+ when_connected { @subscribed_client.subscribe(channel) }
135
135
  end
136
136
  end
137
137
 
138
138
  def remove_channel(channel)
139
139
  @subscription_lock.synchronize do
140
- when_connected { send_command("unsubscribe", channel) }
140
+ when_connected { @subscribed_client.unsubscribe(channel) }
141
141
  end
142
142
  end
143
143
 
@@ -156,22 +156,49 @@ module ActionCable
156
156
  end
157
157
 
158
158
  def when_connected(&block)
159
- if @raw_client
159
+ if @subscribed_client
160
160
  block.call
161
161
  else
162
162
  @when_connected << block
163
163
  end
164
164
  end
165
165
 
166
- def send_command(*command)
167
- @raw_client.write(command)
166
+ if ::Redis::VERSION < "5"
167
+ class SubscribedClient
168
+ def initialize(raw_client)
169
+ @raw_client = raw_client
170
+ end
171
+
172
+ def subscribe(*channel)
173
+ send_command("subscribe", *channel)
174
+ end
175
+
176
+ def unsubscribe(*channel)
177
+ send_command("unsubscribe", *channel)
178
+ end
179
+
180
+ private
181
+ def send_command(*command)
182
+ @raw_client.write(command)
168
183
 
169
- very_raw_connection =
170
- @raw_client.connection.instance_variable_defined?(:@connection) &&
171
- @raw_client.connection.instance_variable_get(:@connection)
184
+ very_raw_connection =
185
+ @raw_client.connection.instance_variable_defined?(:@connection) &&
186
+ @raw_client.connection.instance_variable_get(:@connection)
172
187
 
173
- if very_raw_connection && very_raw_connection.respond_to?(:flush)
174
- very_raw_connection.flush
188
+ if very_raw_connection && very_raw_connection.respond_to?(:flush)
189
+ very_raw_connection.flush
190
+ end
191
+ nil
192
+ end
193
+ end
194
+
195
+ def extract_subscribed_client(conn)
196
+ raw_client = conn.respond_to?(:_client) ? conn._client : conn.client
197
+ SubscribedClient.new(raw_client)
198
+ end
199
+ else
200
+ def extract_subscribed_client(conn)
201
+ conn
175
202
  end
176
203
  end
177
204
  end
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: 7.0.3.1
4
+ version: 7.0.4
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: 2022-07-12 00:00:00.000000000 Z
12
+ date: 2022-09-09 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -17,28 +17,28 @@ dependencies:
17
17
  requirements:
18
18
  - - '='
19
19
  - !ruby/object:Gem::Version
20
- version: 7.0.3.1
20
+ version: 7.0.4
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: 7.0.3.1
27
+ version: 7.0.4
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: actionpack
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
32
  - - '='
33
33
  - !ruby/object:Gem::Version
34
- version: 7.0.3.1
34
+ version: 7.0.4
35
35
  type: :runtime
36
36
  prerelease: false
37
37
  version_requirements: !ruby/object:Gem::Requirement
38
38
  requirements:
39
39
  - - '='
40
40
  - !ruby/object:Gem::Version
41
- version: 7.0.3.1
41
+ version: 7.0.4
42
42
  - !ruby/object:Gem::Dependency
43
43
  name: nio4r
44
44
  requirement: !ruby/object:Gem::Requirement
@@ -142,10 +142,10 @@ licenses:
142
142
  - MIT
143
143
  metadata:
144
144
  bug_tracker_uri: https://github.com/rails/rails/issues
145
- changelog_uri: https://github.com/rails/rails/blob/v7.0.3.1/actioncable/CHANGELOG.md
146
- documentation_uri: https://api.rubyonrails.org/v7.0.3.1/
145
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.4/actioncable/CHANGELOG.md
146
+ documentation_uri: https://api.rubyonrails.org/v7.0.4/
147
147
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
148
- source_code_uri: https://github.com/rails/rails/tree/v7.0.3.1/actioncable
148
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.4/actioncable
149
149
  rubygems_mfa_required: 'true'
150
150
  post_install_message:
151
151
  rdoc_options: []