actioncable 7.0.4.3 → 7.0.7.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2622a0bda2ac4e21aef9acb2345a385ddcb76b9623b0880b81ebef1b135eb1d1
4
- data.tar.gz: f0065045a66e532260bff962f925ae844b230160a1d1e07f33bcbc774941206d
3
+ metadata.gz: f0b157e84c123c5c09c4d01ae257a2be69f755aa995a4fc124be0ff78d51c3f2
4
+ data.tar.gz: fad558caa312b76636d2bc9fe58dfe59a6cd233b83a5e59884c3a146b2a67627
5
5
  SHA512:
6
- metadata.gz: 5f6d3cf4c904c9213e901235c310f12b416a2fcb7570f859463f932fc15b2831988cc8cddf0e4d45d19571143a3cddd19bf9683f35f092cf363f4dcc2eec2506
7
- data.tar.gz: edf288bef934a10d639748750277edd2c8ecf1b4d4cee650bfd8bbd43517923417083f6cc2860f52acb2d0e99c3cb976118dc66e62b180f7cea61669d2503b2a
6
+ metadata.gz: f331494a48497d24d09b299bae351fc4d43b433c8a5a7453ac52be0ea26440172173b2a9c96189558058f5181d8b4093deac7b87f873cb64c7f1eb19d32cb8c2
7
+ data.tar.gz: 98c7611eac2cec92bf2e6e2dd1b03794d5a136c5b45d74472abe3b0b93132e93c519ada3dd8d7e0de3d740dd8e100500367abf769c27ab08859cc2be936f5ca9
data/CHANGELOG.md CHANGED
@@ -1,3 +1,37 @@
1
+ ## Rails 7.0.7.2 (August 22, 2023) ##
2
+
3
+ * No changes.
4
+
5
+
6
+ ## Rails 7.0.7.1 (August 22, 2023) ##
7
+
8
+ * No changes.
9
+
10
+
11
+ ## Rails 7.0.7 (August 09, 2023) ##
12
+
13
+ * No changes.
14
+
15
+
16
+ ## Rails 7.0.6 (June 29, 2023) ##
17
+
18
+ * Fix Action Cable Redis configuration with sentinels.
19
+
20
+ *Dmitriy Ivliev*
21
+
22
+
23
+ ## Rails 7.0.5.1 (June 26, 2023) ##
24
+
25
+ * No changes.
26
+
27
+
28
+ ## Rails 7.0.5 (May 24, 2023) ##
29
+
30
+ * Restore Action Cable Redis pub/sub listener on connection failure.
31
+
32
+ *Vladimir Dementyev*
33
+
34
+
1
35
  ## Rails 7.0.4.3 (March 13, 2023) ##
2
36
 
3
37
  * No changes.
data/README.md CHANGED
@@ -15,7 +15,7 @@ API documentation is at:
15
15
 
16
16
  * https://api.rubyonrails.org
17
17
 
18
- Bug reports for the Ruby on Rails project can be filed here:
18
+ Bug reports for the Ruby on \Rails project can be filed here:
19
19
 
20
20
  * https://github.com/rails/rails/issues
21
21
 
@@ -9,8 +9,8 @@ module ActionCable
9
9
  module VERSION
10
10
  MAJOR = 7
11
11
  MINOR = 0
12
- TINY = 4
13
- PRE = "3"
12
+ TINY = 7
13
+ PRE = "2"
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -46,7 +46,7 @@ module ActionCable
46
46
 
47
47
  private
48
48
  def listener
49
- @listener || @server.mutex.synchronize { @listener ||= Listener.new(self, @server.event_loop) }
49
+ @listener || @server.mutex.synchronize { @listener ||= Listener.new(self, config_options, @server.event_loop) }
50
50
  end
51
51
 
52
52
  def redis_connection_for_broadcasts
@@ -56,11 +56,15 @@ module ActionCable
56
56
  end
57
57
 
58
58
  def redis_connection
59
- self.class.redis_connector.call(@server.config.cable.symbolize_keys.merge(id: identifier))
59
+ self.class.redis_connector.call(config_options)
60
+ end
61
+
62
+ def config_options
63
+ @config_options ||= @server.config.cable.deep_symbolize_keys.merge(id: identifier)
60
64
  end
61
65
 
62
66
  class Listener < SubscriberMap
63
- def initialize(adapter, event_loop)
67
+ def initialize(adapter, config_options, event_loop)
64
68
  super()
65
69
 
66
70
  @adapter = adapter
@@ -69,6 +73,11 @@ module ActionCable
69
73
  @subscribe_callbacks = Hash.new { |h, k| h[k] = [] }
70
74
  @subscription_lock = Mutex.new
71
75
 
76
+ @reconnect_attempt = 0
77
+ # Use the same config as used by Redis conn
78
+ @reconnect_attempts = config_options.fetch(:reconnect_attempts, 1)
79
+ @reconnect_attempts = Array.new(@reconnect_attempts, 0) if @reconnect_attempts.is_a?(Integer)
80
+
72
81
  @subscribed_client = nil
73
82
 
74
83
  @when_connected = []
@@ -84,6 +93,7 @@ module ActionCable
84
93
  on.subscribe do |chan, count|
85
94
  @subscription_lock.synchronize do
86
95
  if count == 1
96
+ @reconnect_attempt = 0
87
97
  @subscribed_client = original_client
88
98
 
89
99
  until @when_connected.empty?
@@ -150,8 +160,16 @@ module ActionCable
150
160
  @thread ||= Thread.new do
151
161
  Thread.current.abort_on_exception = true
152
162
 
153
- conn = @adapter.redis_connection_for_subscriptions
154
- listen conn
163
+ begin
164
+ conn = @adapter.redis_connection_for_subscriptions
165
+ listen conn
166
+ rescue ConnectionError
167
+ reset
168
+ if retry_connecting?
169
+ when_connected { resubscribe }
170
+ retry
171
+ end
172
+ end
155
173
  end
156
174
  end
157
175
 
@@ -163,7 +181,36 @@ module ActionCable
163
181
  end
164
182
  end
165
183
 
184
+ def retry_connecting?
185
+ @reconnect_attempt += 1
186
+
187
+ return false if @reconnect_attempt > @reconnect_attempts.size
188
+
189
+ sleep_t = @reconnect_attempts[@reconnect_attempt - 1]
190
+
191
+ sleep(sleep_t) if sleep_t > 0
192
+
193
+ true
194
+ end
195
+
196
+ def resubscribe
197
+ channels = @sync.synchronize do
198
+ @subscribers.keys
199
+ end
200
+ @subscribed_client.subscribe(*channels) unless channels.empty?
201
+ end
202
+
203
+ def reset
204
+ @subscription_lock.synchronize do
205
+ @subscribed_client = nil
206
+ @subscribe_callbacks.clear
207
+ @when_connected.clear
208
+ end
209
+ end
210
+
166
211
  if ::Redis::VERSION < "5"
212
+ ConnectionError = ::Redis::ConnectionError
213
+
167
214
  class SubscribedClient
168
215
  def initialize(raw_client)
169
216
  @raw_client = raw_client
@@ -197,6 +244,8 @@ module ActionCable
197
244
  SubscribedClient.new(raw_client)
198
245
  end
199
246
  else
247
+ ConnectionError = RedisClient::ConnectionError
248
+
200
249
  def extract_subscribed_client(conn)
201
250
  conn
202
251
  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.4.3
4
+ version: 7.0.7.2
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: 2023-03-13 00:00:00.000000000 Z
12
+ date: 2023-08-22 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.4.3
20
+ version: 7.0.7.2
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.4.3
27
+ version: 7.0.7.2
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.4.3
34
+ version: 7.0.7.2
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.4.3
41
+ version: 7.0.7.2
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.4.3/actioncable/CHANGELOG.md
146
- documentation_uri: https://api.rubyonrails.org/v7.0.4.3/
145
+ changelog_uri: https://github.com/rails/rails/blob/v7.0.7.2/actioncable/CHANGELOG.md
146
+ documentation_uri: https://api.rubyonrails.org/v7.0.7.2/
147
147
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
148
- source_code_uri: https://github.com/rails/rails/tree/v7.0.4.3/actioncable
148
+ source_code_uri: https://github.com/rails/rails/tree/v7.0.7.2/actioncable
149
149
  rubygems_mfa_required: 'true'
150
150
  post_install_message:
151
151
  rdoc_options: []
@@ -162,7 +162,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
162
162
  - !ruby/object:Gem::Version
163
163
  version: '0'
164
164
  requirements: []
165
- rubygems_version: 3.4.3
165
+ rubygems_version: 3.3.3
166
166
  signing_key:
167
167
  specification_version: 4
168
168
  summary: WebSocket framework for Rails.