rmessage 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rmessage/publisher.rb +3 -2
- data/lib/rmessage/subscriber.rb +5 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 01d9e52b3e8082a074ff5d01c477c26ebb1000351b7b852b9e0de5755bc3fb96
|
4
|
+
data.tar.gz: e46587aff7eb07d66d273d5e4540f61bfe1e36c2e5029ee1b60ac5926b91917e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31c38a6a34571cede4239c56177f77ad2fe41805499b5adff88b52117c4ba4c1f081d3d7ef6b3e963adf21f096a032c9aed76942423423455481a1f977c61922
|
7
|
+
data.tar.gz: 33001b0b8853432550828937bfca3ad53704d14b2a717bcff091ed857f84704494b4b5499fa264b1b42bf31841c3605e589fbe7e5750f7880c1770078b3fa896
|
data/lib/rmessage/publisher.rb
CHANGED
@@ -10,7 +10,8 @@ module RMessage::Publisher
|
|
10
10
|
# @param message [RMessage::Message] the message
|
11
11
|
# @param channel [String, Integer, Symbol] the channel
|
12
12
|
# @param connection_index [Integer] the index of the connection to Redis within the {RMessage::CONNECTION_POOL}
|
13
|
-
def publish(message, channel: @channel, connection_index: 0)
|
14
|
-
RMessage::CONNECTION_POOL[connection_index]
|
13
|
+
def publish(message, channel: @channel, connection: nil, connection_index: 0)
|
14
|
+
redis_connection = connection || RMessage::CONNECTION_POOL[connection_index]
|
15
|
+
redis_connection.publish(channel, message.build)
|
15
16
|
end
|
16
17
|
end
|
data/lib/rmessage/subscriber.rb
CHANGED
@@ -13,13 +13,12 @@ module RMessage::Subscriber
|
|
13
13
|
# Setup a subscription to a specific Redis channel
|
14
14
|
# @param channel [Symbol, String, Integer] the channel
|
15
15
|
# @param auto_parse [Boolean] should messages be parsed automatically?
|
16
|
+
# @param connection [Redis] optional argument to provide the redis connection.
|
16
17
|
# @param connection_index [Integer] the index of the redis connection in {RMessage::CONNECTION_POOL}
|
17
|
-
def setup_subscription(channel: @channel, auto_parse: false, connection_index: 0, &_)
|
18
|
-
RMessage::CONNECTION_POOL[connection_index]
|
19
|
-
|
20
|
-
|
21
|
-
end
|
22
|
-
|
18
|
+
def setup_subscription(channel: @channel, auto_parse: false, connection: nil, connection_index: 0, &_)
|
19
|
+
redis_connection = connection || RMessage::CONNECTION_POOL[connection_index]
|
20
|
+
redis_connection.subscribe(channel) do |event|
|
21
|
+
event.subscribe { puts "Subscribed to #{channel}" }
|
23
22
|
if auto_parse
|
24
23
|
event.message { |_, message| parse_message(message) }
|
25
24
|
else
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rmessage
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Patrick W.
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-03-
|
11
|
+
date: 2022-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dotenv
|