solid_cable 3.0.8 → 3.0.10

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: a0a720657c2026c2b54d9318eb7f9f66ed15b9d303d1c396c0328b9a5133a3c5
4
- data.tar.gz: b73482b38813c809cfadcefc31ec0003f28000a9d911c41905f156dfe1e5cc94
3
+ metadata.gz: 1f58b4cc20ab57b3a84773c5e86cb01ff4a26cb2ab2ec0467db62d6d44a0cd34
4
+ data.tar.gz: ea3a3b978b731f2c8b8a6da3e565fdd3618276fad5ca0360e2583e8938ae2121
5
5
  SHA512:
6
- metadata.gz: 8856d9432a9c81cc604133fdb7defe84c5f111454183e9ee4baf165ac4780bf04c88466187329fd591ccf215ee58014501ea197d525cfc065b7c1713454e3fdb
7
- data.tar.gz: 5bc0f318209db0f1b981ef0e7ad0687a1c2af8ae515f9975b2cff46017265ce33243dafdf6d8f4524efb49737fb9adfb283328944e823943d7878a32f6a235a0
6
+ metadata.gz: d4e1abe347443f90c6e443721b3820910c567bfe8c7b8d6b4beb4f8849d2ad7816b7c334253215cf0668a7ecb672349ac2d5698ad6f3e55463734381ad442d18
7
+ data.tar.gz: e29b2151e8aeb9ce7b74f7f207f2777e1f83ca08eab200978b541d6bfeb87cbc281f0248357a115e1781f3b1439c5f862da7a66ae213ee719447e2998aeaa96f
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.
@@ -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.8"
4
+ VERSION = "3.0.10"
5
5
  end
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: 3.0.8
4
+ version: 3.0.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Pezza
@@ -112,7 +112,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
112
112
  - !ruby/object:Gem::Version
113
113
  version: '0'
114
114
  requirements: []
115
- rubygems_version: 3.6.8
115
+ rubygems_version: 3.6.9
116
116
  specification_version: 4
117
117
  summary: Database-backed Action Cable backend.
118
118
  test_files: []