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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 027c26a46e85945a595e17f63f468b7db4bbc5445e62337e72aba85136ebd089
4
- data.tar.gz: 5059e66328f264c26c20d42ab152dc4d1486b02f7990a87dec54560f94455def
3
+ metadata.gz: 01d9e52b3e8082a074ff5d01c477c26ebb1000351b7b852b9e0de5755bc3fb96
4
+ data.tar.gz: e46587aff7eb07d66d273d5e4540f61bfe1e36c2e5029ee1b60ac5926b91917e
5
5
  SHA512:
6
- metadata.gz: a7a1371e9e285c7f8313478f8ee7ecdce68d90b411922ed321d634781122a375534278439bfa02c175bfd1448212f08008339ada3b73e23306d27554e56cde21
7
- data.tar.gz: ffdc5a57b6e9d5a99f9f22536478c45287076cc03a1fa2ac6ce25778f90b8b9e3f3ea316632a7d771c995f6c97e912ab479f4181010c2ee696513b3d415718b7
6
+ metadata.gz: 31c38a6a34571cede4239c56177f77ad2fe41805499b5adff88b52117c4ba4c1f081d3d7ef6b3e963adf21f096a032c9aed76942423423455481a1f977c61922
7
+ data.tar.gz: 33001b0b8853432550828937bfca3ad53704d14b2a717bcff091ed857f84704494b4b5499fa264b1b42bf31841c3605e589fbe7e5750f7880c1770078b3fa896
@@ -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].publish(channel, message.build)
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
@@ -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].subscribe(channel) do |event|
19
- event.subscribe do
20
- puts "Subscribed to #{channel}"
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.0
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 00:00:00.000000000 Z
11
+ date: 2022-03-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: dotenv