pubsubstub 0.3.0 → 0.3.1
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/.github/workflows/ci.yml +3 -0
- data/lib/pubsubstub/subscriber.rb +4 -4
- data/lib/pubsubstub/version.rb +1 -1
- data/lib/pubsubstub.rb +4 -5
- data/pubsubstub.gemspec +1 -0
- metadata +17 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '02587c35a55071e5c8a281b9b553cc972fac8da1ed56f93814368e2445f064aa'
|
4
|
+
data.tar.gz: 6e1bb8fd6632ff4eae6babd24171f3c9fd9ba5b782ff47c7cdfc18ba4f5b3615
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2189065ad79093d3e8fefa0e3005fb7874585ff864d9a3be73d58a05a1ef7bd4e24b742f7a832270731faac35f6440411dfe47d121a4b922179096bdc810330c
|
7
|
+
data.tar.gz: 171f9186353564bbfdf95420cfcc4fc9fb8ff07dfbc0697aa2f793095007c94753a0d410055ce60385b0b1ae3830f07314dfc1ed62804eaa1a7c7d660e049ae6
|
data/.github/workflows/ci.yml
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
module Pubsubstub
|
2
2
|
class Subscriber
|
3
3
|
include Logging
|
4
|
-
include Mutex_m
|
5
4
|
|
6
5
|
def initialize
|
7
6
|
super
|
7
|
+
@mutex = Mutex.new
|
8
8
|
@subscribed = false
|
9
9
|
@listeners = {}
|
10
10
|
end
|
@@ -14,14 +14,14 @@ module Pubsubstub
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_event_listener(channel_key, callback)
|
17
|
-
synchronize do
|
17
|
+
@mutex.synchronize do
|
18
18
|
@listeners[channel_key] ||= Set.new
|
19
19
|
!!@listeners[channel_key].add?(callback)
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def remove_event_listener(channel_key, callback)
|
24
|
-
synchronize do
|
24
|
+
@mutex.synchronize do
|
25
25
|
return unless @listeners[channel_key]
|
26
26
|
!!@listeners[channel_key].delete?(callback)
|
27
27
|
end
|
@@ -30,7 +30,7 @@ module Pubsubstub
|
|
30
30
|
def stop
|
31
31
|
# redis.client.call allow to bypass the client mutex
|
32
32
|
# Since we now that the only other possible caller is blocking on reading the socket this is safe
|
33
|
-
synchronize do
|
33
|
+
@mutex.synchronize do
|
34
34
|
redis._client.call(['punsubscribe', pubsub_pattern])
|
35
35
|
end
|
36
36
|
end
|
data/lib/pubsubstub/version.rb
CHANGED
data/lib/pubsubstub.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
require "logger"
|
2
|
-
require "mutex_m"
|
3
2
|
require "json"
|
4
3
|
require "set"
|
5
4
|
|
@@ -17,7 +16,7 @@ require "pubsubstub/publish_action"
|
|
17
16
|
require "pubsubstub/application"
|
18
17
|
|
19
18
|
module Pubsubstub
|
20
|
-
|
19
|
+
@mutex = Mutex.new
|
21
20
|
|
22
21
|
class << self
|
23
22
|
attr_accessor :heartbeat_frequency, :redis_url, :channels_scrollback_size,
|
@@ -35,11 +34,11 @@ module Pubsubstub
|
|
35
34
|
end
|
36
35
|
|
37
36
|
def redis
|
38
|
-
@redis || synchronize { @redis ||= new_redis }
|
37
|
+
@redis || @mutex.synchronize { @redis ||= new_redis }
|
39
38
|
end
|
40
39
|
|
41
40
|
def redis=(client)
|
42
|
-
synchronize { @redis = client }
|
41
|
+
@mutex.synchronize { @redis = client }
|
43
42
|
end
|
44
43
|
|
45
44
|
def new_redis
|
@@ -47,7 +46,7 @@ module Pubsubstub
|
|
47
46
|
end
|
48
47
|
|
49
48
|
def subscriber
|
50
|
-
@subscriber || synchronize { @subscriber ||= Subscriber.new }
|
49
|
+
@subscriber || @mutex.synchronize { @subscriber ||= Subscriber.new }
|
51
50
|
end
|
52
51
|
|
53
52
|
def heartbeat_event
|
data/pubsubstub.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pubsubstub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Guillaume Malette
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 2025-07-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: rack
|
@@ -24,6 +23,20 @@ dependencies:
|
|
24
23
|
- - ">="
|
25
24
|
- !ruby/object:Gem::Version
|
26
25
|
version: '0'
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: logger
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '0'
|
27
40
|
- !ruby/object:Gem::Dependency
|
28
41
|
name: redis
|
29
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +112,6 @@ homepage: https://github.com/byroot/pubsubstub
|
|
99
112
|
licenses:
|
100
113
|
- MIT
|
101
114
|
metadata: {}
|
102
|
-
post_install_message:
|
103
115
|
rdoc_options: []
|
104
116
|
require_paths:
|
105
117
|
- lib
|
@@ -114,8 +126,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
114
126
|
- !ruby/object:Gem::Version
|
115
127
|
version: '0'
|
116
128
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
129
|
+
rubygems_version: 3.6.2
|
119
130
|
specification_version: 4
|
120
131
|
summary: Pubsubstub is a rack middleware to add Pub/Sub
|
121
132
|
test_files:
|