solid_cable 3.0.7 → 3.0.9

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: c539a7fa2b2a380a1eba731b6b648a50cab649feeafffac427e37a283fa14ca3
4
- data.tar.gz: 2b067b5c80b211a0e89b8d72a46ed4559e9c880e9845688cdc3ea11a3e3527c1
3
+ metadata.gz: 3fafe8af9b261e7adba2e7b99b129b17c55b46392b2cea439f1e777cef31504b
4
+ data.tar.gz: a679eb8d733d200096a9c8d68dae373fa2d7e5be8c6997d0e921d33b44859ab8
5
5
  SHA512:
6
- metadata.gz: dd4c81ee1b1e2bd2f024fed7b1561b8eb24d8fb7f2ee16e7efce9dd0a3409a197446936194a272cecc293e81e62e119ad7100395ba6c5fc453b0213e5415adca
7
- data.tar.gz: f30f1987f739b5a7b0afded103e3cf337343570b7483f2118f47116e325cd0a7db2865363e560b3c9dcd689291c55fd4c128eebe56be3d7d8411f53d6d41b2c0
6
+ metadata.gz: eb568512d91c70cc77245c86d69136f763f2969c0fdbc9b5d4284faf552c1c1f8ca0bba13cec656192741aee2978c6a0f001e1659f050ad3086b30ce46905fd6
7
+ data.tar.gz: f5bcec74d6a197dd3481d36d233e68b1cd430c48fc40c09524060ee3129ff33f1c631c8f6589301a81cf1b28ba906a0369481d5ef9ae55fe7061b452478968ef
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Solid Cable
2
2
 
3
- Solid Cable is a database-backed Action Cable adapter that keeps messages in a table and continously polls for updates. This makes it possible to drop the common dependency on Redis, if it isn't needed for any other purpose. Despite polling, the performance of Solid Cable is comparable to Redis in most situations. And in all circumstances, it makes it easier to deploy Rails when Redis is no longer a required dependency for Action Cable functionality.
3
+ Solid Cable is a database-backed Action Cable adapter that keeps messages in a table and continuously polls for updates. This makes it possible to drop the common dependency on Redis, if it isn't needed for any other purpose. Despite polling, the performance of Solid Cable is comparable to Redis in most situations. And in all circumstances, it makes it easier to deploy Rails when Redis is no longer a required dependency for Action Cable functionality.
4
4
 
5
5
  > [!NOTE]
6
6
  > Solid Cable is tested to work with MySQL, SQLite, and PostgreSQL.
@@ -20,7 +20,8 @@ module SolidCable
20
20
  def trim?
21
21
  expires_per_write = (1 / trim_batch_size.to_f) * ::SolidCable.trim_chance
22
22
 
23
- rand < (expires_per_write - expires_per_write.floor)
23
+ !::SolidCable.autotrim? ||
24
+ rand < (expires_per_write - expires_per_write.floor)
24
25
  end
25
26
  end
26
27
  end
@@ -7,7 +7,7 @@ module SolidCable
7
7
  }
8
8
  scope :broadcastable, lambda { |channels, last_id|
9
9
  where(channel_hash: channel_hashes_for(channels)).
10
- where(id: (last_id + 1)..).order(:id)
10
+ where(id: (last_id.to_i + 1)..).order(:id)
11
11
  }
12
12
 
13
13
  class << self
@@ -89,7 +89,7 @@ module ActionCable
89
89
  end
90
90
 
91
91
  def add_channel(channel, on_success)
92
- channels.add(channel)
92
+ channels[channel] = last_message_id
93
93
  event_loop.post(&on_success) if on_success
94
94
  end
95
95
 
@@ -103,21 +103,22 @@ module ActionCable
103
103
 
104
104
  private
105
105
  attr_reader :event_loop, :thread
106
- attr_writer :last_id
107
106
 
108
- def last_id
109
- @last_id ||= ::SolidCable::Message.maximum(:id) || 0
107
+ def last_message_id
108
+ ::SolidCable::Message.maximum(:id) || 0
110
109
  end
111
110
 
112
111
  def channels
113
- @channels ||= Set.new
112
+ @channels ||= Concurrent::Hash.new
114
113
  end
115
114
 
116
115
  def broadcast_messages
117
- ::SolidCable::Message.broadcastable(channels, last_id).
116
+ ::SolidCable::Message.broadcastable(channels.keys, channels.values.min).
118
117
  each do |message|
119
- broadcast(message.channel, message.payload)
120
- self.last_id = message.id
118
+ if channels[message.channel].present? && channels[message.channel] < message.id
119
+ broadcast(message.channel, message.payload)
120
+ channels[message.channel] = message.id
121
+ end
121
122
  end
122
123
  end
123
124
 
@@ -128,37 +129,6 @@ module ActionCable
128
129
  yield
129
130
  end
130
131
  end
131
-
132
- def wake_up
133
- interrupt
134
- end
135
-
136
- SELF_PIPE_BLOCK_SIZE = 11
137
-
138
- def interrupt
139
- self_pipe[:writer].write_nonblock(".")
140
- rescue Errno::EAGAIN, Errno::EINTR
141
- # Ignore writes that would block and retry
142
- # if another signal arrived while writing
143
- retry
144
- end
145
-
146
- def interruptible_sleep(time)
147
- if time > 0 && self_pipe[:reader].wait_readable(time)
148
- loop { self_pipe[:reader].read_nonblock(SELF_PIPE_BLOCK_SIZE) }
149
- end
150
- rescue Errno::EAGAIN, Errno::EINTR
151
- end
152
-
153
- # Self-pipe for signal-handling (http://cr.yp.to/docs/selfpipe.html)
154
- def self_pipe
155
- @self_pipe ||= create_self_pipe
156
- end
157
-
158
- def create_self_pipe
159
- reader, writer = IO.pipe
160
- { reader: reader, writer: writer }
161
- end
162
132
  end
163
133
  end
164
134
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module SolidCable
4
- VERSION = "3.0.7"
4
+ VERSION = "3.0.9"
5
5
  end
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: solid_cable
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.7
4
+ version: 3.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-01-25 00:00:00.000000000 Z
10
+ date: 1980-01-02 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
13
  name: activerecord
@@ -99,7 +98,6 @@ metadata:
99
98
  homepage_uri: https://github.com/rails/solid_cable
100
99
  source_code_uri: https://github.com/rails/solid_cable
101
100
  rubygems_mfa_required: 'true'
102
- post_install_message:
103
101
  rdoc_options: []
104
102
  require_paths:
105
103
  - lib
@@ -114,8 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
112
  - !ruby/object:Gem::Version
115
113
  version: '0'
116
114
  requirements: []
117
- rubygems_version: 3.5.18
118
- signing_key:
115
+ rubygems_version: 3.6.9
119
116
  specification_version: 4
120
117
  summary: Database-backed Action Cable backend.
121
118
  test_files: []