rmessage 0.1.1 → 0.1.2
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/lib/rmessage/subscriber.rb +8 -6
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f771b5b481689023a94dec959210999ef38cd0e043b7d32b60f2cf66e45f7f6c
|
4
|
+
data.tar.gz: b05c425ee17726307234565fc174c07485b551fe7560db3a8df33a93f82a34f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29a45abc74618f7c559da04ca0728fbc5979c211510185f311acf6178621e32bdd984d1e8d93c317c263a953aef00726c40c7dab6837959144d786af7fe7d383
|
7
|
+
data.tar.gz: ffd9e32788dcf26e1647f9846ee9122f1b83e497b69e5c81abc996ce2c431db49449848415aacf20e8c763cf6793f54fdaed6287928f51afa7b058410ee64cfe
|
data/lib/rmessage/subscriber.rb
CHANGED
@@ -15,14 +15,16 @@ module RMessage::Subscriber
|
|
15
15
|
# @param auto_parse [Boolean] should messages be parsed automatically?
|
16
16
|
# @param connection [Redis] optional argument to provide the redis connection.
|
17
17
|
# @param connection_index [Integer] the index of the redis connection in {RMessage::CONNECTION_POOL}
|
18
|
-
def setup_subscription(channel: @channel, auto_parse: false, connection: nil, connection_index: 0, &_)
|
18
|
+
def setup_subscription(channel: @channel, auto_parse: false, logger: nil, connection: nil, connection_index: 0, &_)
|
19
19
|
redis_connection = connection || RMessage::CONNECTION_POOL[connection_index]
|
20
20
|
redis_connection.subscribe(channel) do |event|
|
21
|
-
event.subscribe
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
event.subscribe do
|
22
|
+
logger&.info("Subscribed to channel [channel: #{channel}]")
|
23
|
+
end
|
24
|
+
|
25
|
+
event.message do |_, message|
|
26
|
+
auto_parse ? parse_message(message) : yield(message)
|
27
|
+
logger&.info("Received Message: #{message}")
|
26
28
|
end
|
27
29
|
end
|
28
30
|
end
|