solid_cable 3.0.5 → 3.0.6
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 807dfe75fdc4577c47485b8af3a296eddc6655f53d2294bc831fc1862127214e
|
4
|
+
data.tar.gz: 48b1b21d6e60e0532f6a7ea542e3cda8384d4178256c81cffa184c4bebaee721
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: '099db3f19f50a76ea75881f3a01efc73a0ae1a60aee20cce9f8be0e06dc9cfe3de5beb574a212cc34d2eca33103e367d4d09a649340b49777c76bda09bb04320'
|
7
|
+
data.tar.gz: e519ed0fcd86350fd107db0d90717466676029f9471f26b9544bd970684d39993b0585b8d4c848b482bca21aa2924de4f8790655f7a36c4cb0d7bc10c5f91610
|
@@ -3,6 +3,7 @@
|
|
3
3
|
require "action_cable/subscription_adapter/base"
|
4
4
|
require "action_cable/subscription_adapter/channel_prefix"
|
5
5
|
require "action_cable/subscription_adapter/subscriber_map"
|
6
|
+
require "concurrent/atomic/semaphore"
|
6
7
|
|
7
8
|
module ActionCable
|
8
9
|
module SubscriptionAdapter
|
@@ -38,34 +39,53 @@ module ActionCable
|
|
38
39
|
end
|
39
40
|
|
40
41
|
class Listener < ::ActionCable::SubscriptionAdapter::SubscriberMap
|
42
|
+
Stop = Class.new(Exception)
|
43
|
+
|
41
44
|
def initialize(event_loop)
|
42
45
|
super()
|
43
46
|
|
44
47
|
@event_loop = event_loop
|
45
48
|
|
49
|
+
# Critical section begins with 0 permits. It can be understood as
|
50
|
+
# being "normally held" by the listener thread. It is released
|
51
|
+
# for specific sections of code, rather than acquired.
|
52
|
+
@critical = Concurrent::Semaphore.new(0)
|
53
|
+
|
46
54
|
@thread = Thread.new do
|
47
|
-
Thread.current.abort_on_exception = true
|
48
55
|
listen
|
49
56
|
end
|
50
57
|
end
|
51
58
|
|
52
59
|
def listen
|
53
60
|
loop do
|
54
|
-
|
55
|
-
|
56
|
-
|
61
|
+
begin
|
62
|
+
instance = interruptible { Rails.application.executor.run! }
|
63
|
+
with_polling_volume { broadcast_messages }
|
64
|
+
ensure
|
65
|
+
instance.complete! if instance
|
66
|
+
end
|
57
67
|
|
58
|
-
|
68
|
+
interruptible { sleep ::SolidCable.polling_interval }
|
59
69
|
end
|
70
|
+
rescue Stop
|
71
|
+
ensure
|
72
|
+
@critical.release
|
60
73
|
end
|
61
74
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
75
|
+
def interruptible
|
76
|
+
@critical.release
|
77
|
+
yield
|
78
|
+
ensure
|
79
|
+
@critical.acquire
|
80
|
+
end
|
65
81
|
|
66
|
-
|
67
|
-
|
68
|
-
|
82
|
+
def shutdown
|
83
|
+
@critical.acquire
|
84
|
+
# We have the critical permit, and so the listen thread must be
|
85
|
+
# safe to interrupt.
|
86
|
+
thread.raise(Stop)
|
87
|
+
@critical.release
|
88
|
+
thread.join
|
69
89
|
end
|
70
90
|
|
71
91
|
def add_channel(channel, on_success)
|
@@ -83,15 +103,7 @@ module ActionCable
|
|
83
103
|
|
84
104
|
private
|
85
105
|
attr_reader :event_loop, :thread
|
86
|
-
attr_writer :
|
87
|
-
|
88
|
-
def running?
|
89
|
-
if defined?(@running)
|
90
|
-
@running
|
91
|
-
else
|
92
|
-
self.running = true
|
93
|
-
end
|
94
|
-
end
|
106
|
+
attr_writer :last_id
|
95
107
|
|
96
108
|
def last_id
|
97
109
|
@last_id ||= ::SolidCable::Message.maximum(:id) || 0
|
@@ -102,12 +114,10 @@ module ActionCable
|
|
102
114
|
end
|
103
115
|
|
104
116
|
def broadcast_messages
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
self.last_id = message.id
|
110
|
-
end
|
117
|
+
::SolidCable::Message.broadcastable(channels, last_id).
|
118
|
+
each do |message|
|
119
|
+
broadcast(message.channel, message.payload)
|
120
|
+
self.last_id = message.id
|
111
121
|
end
|
112
122
|
end
|
113
123
|
|
data/lib/solid_cable/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: solid_cable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nick Pezza
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|