solid_cable 3.0.11 → 4.0.0
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/README.md +2 -0
- data/Rakefile +3 -2
- data/lib/action_cable/subscription_adapter/solid_cable.rb +41 -5
- data/lib/solid_cable/version.rb +1 -1
- data/lib/solid_cable.rb +6 -0
- metadata +17 -4
- data/lib/solid_cable/railtie.rb +0 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 82d0f5f6a07f329cf8365e30926b72879b22300fab4c7520d18c865dc184156a
|
|
4
|
+
data.tar.gz: 7e9bd94004f0111b403b31b30f9aa6eb489173f523af656a2db76f771fc7a7c0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: adc3ddc71a3033b4bea6fdd5cc94cf54ca29c39d527d763c0476cd0a99639f94fea18f7a4dd43729da1a20bcb179f900cc95167ac3ea3b95e7186dcd9b048e30
|
|
7
|
+
data.tar.gz: 96ac0c12361e6a9e39a1f5fe0c33975d437e3f6dc1e9038ddda243eef49390bf7078a03d7da7901a4b286f1bd3fc50d9a5edb3caf3877ab887af3ee51d238b64
|
data/README.md
CHANGED
|
@@ -86,6 +86,8 @@ The options are:
|
|
|
86
86
|
- `silence_polling` - whether to silence Active Record logs emitted when polling (Defaults to true)
|
|
87
87
|
- `use_skip_locked` - whether to use `FOR UPDATE SKIP LOCKED` when performing trimming. This will be automatically detected in the future, and for now, you'd only need to set this to `false` if your database doesn't support it. For MySQL, that'd be versions < 8, and for PostgreSQL, versions < 9.5. If you use SQLite, this has no effect, as writes are sequential. (Defaults to true)
|
|
88
88
|
- `trim_batch_size` - the batch size to use when deleting old records (default: `100`)
|
|
89
|
+
- `reconnect_attempts` - Supports a number of connection attempts or an array of
|
|
90
|
+
durations to wait between attempts. (Defaults to 1 retry attempt)
|
|
89
91
|
|
|
90
92
|
|
|
91
93
|
## Trimming
|
data/Rakefile
CHANGED
|
@@ -39,6 +39,11 @@ module ActionCable
|
|
|
39
39
|
end
|
|
40
40
|
|
|
41
41
|
class Listener < ::ActionCable::SubscriptionAdapter::SubscriberMap
|
|
42
|
+
CONNECTION_ERRORS = [
|
|
43
|
+
ActiveRecord::ConnectionFailed,
|
|
44
|
+
ActiveRecord::ConnectionTimeoutError,
|
|
45
|
+
ActiveRecord::ConnectionNotEstablished
|
|
46
|
+
]
|
|
42
47
|
Stop = Class.new(Exception)
|
|
43
48
|
|
|
44
49
|
def initialize(event_loop)
|
|
@@ -51,8 +56,18 @@ module ActionCable
|
|
|
51
56
|
# for specific sections of code, rather than acquired.
|
|
52
57
|
@critical = Concurrent::Semaphore.new(0)
|
|
53
58
|
|
|
59
|
+
@reconnect_attempt = 0
|
|
60
|
+
@last_id = last_message_id
|
|
61
|
+
|
|
54
62
|
@thread = Thread.new do
|
|
55
|
-
|
|
63
|
+
Thread.current.name = "solid_cable_listener"
|
|
64
|
+
Thread.current.report_on_exception = true
|
|
65
|
+
|
|
66
|
+
begin
|
|
67
|
+
listen
|
|
68
|
+
rescue *CONNECTION_ERRORS
|
|
69
|
+
retry if retry_connecting?
|
|
70
|
+
end
|
|
56
71
|
end
|
|
57
72
|
end
|
|
58
73
|
|
|
@@ -103,6 +118,7 @@ module ActionCable
|
|
|
103
118
|
|
|
104
119
|
private
|
|
105
120
|
attr_reader :event_loop, :thread
|
|
121
|
+
attr_accessor :last_id, :reconnect_attempt
|
|
106
122
|
|
|
107
123
|
def last_message_id
|
|
108
124
|
::SolidCable::Message.maximum(:id) || 0
|
|
@@ -116,14 +132,18 @@ module ActionCable
|
|
|
116
132
|
current_channels = channels.dup
|
|
117
133
|
|
|
118
134
|
::SolidCable::Message.
|
|
119
|
-
broadcastable(current_channels.keys,
|
|
135
|
+
broadcastable(current_channels.keys, last_id).
|
|
120
136
|
each do |message|
|
|
121
|
-
|
|
122
|
-
|
|
137
|
+
should_broadcast_message = false
|
|
138
|
+
channels.compute_if_present(message.channel) do |channel_last_id|
|
|
139
|
+
break if channel_last_id >= message.id
|
|
123
140
|
|
|
124
|
-
|
|
141
|
+
should_broadcast_message = true
|
|
125
142
|
message.id
|
|
126
143
|
end
|
|
144
|
+
|
|
145
|
+
broadcast(message.channel, message.payload) if should_broadcast_message
|
|
146
|
+
self.last_id = message.id
|
|
127
147
|
end
|
|
128
148
|
end
|
|
129
149
|
|
|
@@ -134,6 +154,22 @@ module ActionCable
|
|
|
134
154
|
yield
|
|
135
155
|
end
|
|
136
156
|
end
|
|
157
|
+
|
|
158
|
+
def reconnect_attempts
|
|
159
|
+
@reconnect_attempts ||= ::SolidCable.reconnect_attempts
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def retry_connecting?
|
|
163
|
+
self.reconnect_attempt += 1
|
|
164
|
+
|
|
165
|
+
return false if reconnect_attempt > reconnect_attempts.size
|
|
166
|
+
|
|
167
|
+
sleep_t = reconnect_attempts[reconnect_attempt - 1]
|
|
168
|
+
|
|
169
|
+
sleep(sleep_t) if sleep_t > 0
|
|
170
|
+
|
|
171
|
+
true
|
|
172
|
+
end
|
|
137
173
|
end
|
|
138
174
|
end
|
|
139
175
|
end
|
data/lib/solid_cable/version.rb
CHANGED
data/lib/solid_cable.rb
CHANGED
|
@@ -48,6 +48,12 @@ module SolidCable
|
|
|
48
48
|
2
|
|
49
49
|
end
|
|
50
50
|
|
|
51
|
+
def reconnect_attempts
|
|
52
|
+
attempts = cable_config.fetch(:reconnect_attempts, 1)
|
|
53
|
+
attempts = Array.new(attempts, 0) if attempts.is_a?(Integer)
|
|
54
|
+
attempts
|
|
55
|
+
end
|
|
56
|
+
|
|
51
57
|
private
|
|
52
58
|
def cable_config
|
|
53
59
|
Rails.application.config_for("cable")
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: solid_cable
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version:
|
|
4
|
+
version: 4.0.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Nick Pezza
|
|
@@ -65,6 +65,20 @@ dependencies:
|
|
|
65
65
|
- - ">="
|
|
66
66
|
- !ruby/object:Gem::Version
|
|
67
67
|
version: '7.2'
|
|
68
|
+
- !ruby/object:Gem::Dependency
|
|
69
|
+
name: minitest
|
|
70
|
+
requirement: !ruby/object:Gem::Requirement
|
|
71
|
+
requirements:
|
|
72
|
+
- - "~>"
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: '5.0'
|
|
75
|
+
type: :development
|
|
76
|
+
prerelease: false
|
|
77
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
+
requirements:
|
|
79
|
+
- - "~>"
|
|
80
|
+
- !ruby/object:Gem::Version
|
|
81
|
+
version: '5.0'
|
|
68
82
|
description: Database-backed Action Cable backend.
|
|
69
83
|
email:
|
|
70
84
|
- pezza@hey.com
|
|
@@ -88,7 +102,6 @@ files:
|
|
|
88
102
|
- lib/generators/solid_cable/update/update_generator.rb
|
|
89
103
|
- lib/solid_cable.rb
|
|
90
104
|
- lib/solid_cable/engine.rb
|
|
91
|
-
- lib/solid_cable/railtie.rb
|
|
92
105
|
- lib/solid_cable/version.rb
|
|
93
106
|
- lib/tasks/solid_cable_tasks.rake
|
|
94
107
|
homepage: https://github.com/rails/solid_cable
|
|
@@ -105,14 +118,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
105
118
|
requirements:
|
|
106
119
|
- - ">="
|
|
107
120
|
- !ruby/object:Gem::Version
|
|
108
|
-
version: 3.
|
|
121
|
+
version: 3.3.0
|
|
109
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
110
123
|
requirements:
|
|
111
124
|
- - ">="
|
|
112
125
|
- !ruby/object:Gem::Version
|
|
113
126
|
version: '0'
|
|
114
127
|
requirements: []
|
|
115
|
-
rubygems_version:
|
|
128
|
+
rubygems_version: 4.0.10
|
|
116
129
|
specification_version: 4
|
|
117
130
|
summary: Database-backed Action Cable backend.
|
|
118
131
|
test_files: []
|