mumukit-nuntius 5.0.0 → 6.0.0
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 +5 -5
- data/lib/mumukit/nuntius/connection.rb +8 -5
- data/lib/mumukit/nuntius/consumer.rb +1 -2
- data/lib/mumukit/nuntius/notification_mode/deaf.rb +3 -0
- data/lib/mumukit/nuntius/notification_mode/nuntius.rb +4 -0
- data/lib/mumukit/nuntius/publisher.rb +2 -2
- data/lib/mumukit/nuntius/version.rb +1 -1
- data/lib/mumukit/nuntius.rb +4 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5b704fba179d7c036aa3ad060ee1e3251decbe830e83ebe9aff02ad6b2b2bdb5
|
4
|
+
data.tar.gz: f1c22a0ad81c448f90fb84b54d9f40b1d671a246be68391b73b20be703554ac3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ad9478d4d27f72ec082119b9f5470c7a1947c6b761918ed845927b06f5448d01718aa927970e770b2cac22f9edc0276140bc4f4bae0b3c82a3b8c96d38dcd5c
|
7
|
+
data.tar.gz: aff6e9d6f45e848c7a3fcebbe78c397079e9185454a7cb26daef19abf4eeebacf3ac7ce7454e65d91e869da27d12253adeb8b2e07d4fc69b51b4605f6be4b870
|
@@ -1,17 +1,20 @@
|
|
1
1
|
class Mumukit::Nuntius::Connection
|
2
2
|
|
3
3
|
class << self
|
4
|
-
|
5
4
|
def config
|
6
5
|
@config ||= YAML.load_interpolated(File.expand_path '../../../../config/rabbit.yml', __FILE__).
|
7
6
|
with_indifferent_access[ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development']
|
8
7
|
end
|
9
8
|
|
10
|
-
def
|
11
|
-
|
12
|
-
channel = connection.start.create_channel
|
9
|
+
def start_channel(exchange_name)
|
10
|
+
raise 'Nuntius connection isn\'t established' unless @connection
|
11
|
+
channel = @connection.start.create_channel
|
13
12
|
exchange = channel.fanout(exchange_name)
|
14
|
-
[
|
13
|
+
[channel, exchange]
|
14
|
+
end
|
15
|
+
|
16
|
+
def establish_connection
|
17
|
+
@connection = Bunny.new(host: config[:host], user: config[:user], password: config[:password])
|
15
18
|
end
|
16
19
|
end
|
17
20
|
end
|
@@ -5,7 +5,7 @@ module Mumukit::Nuntius::Consumer
|
|
5
5
|
def start(queue_name, exchange_name, &block)
|
6
6
|
Mumukit::Nuntius::Logger.info "Attaching to queue #{queue_name}"
|
7
7
|
|
8
|
-
|
8
|
+
channel, exchange = Mumukit::Nuntius::Connection.start_channel(exchange_name)
|
9
9
|
queue = channel.queue(queue_name, durable: true)
|
10
10
|
queue.bind(exchange)
|
11
11
|
channel.prefetch(1)
|
@@ -16,7 +16,6 @@ module Mumukit::Nuntius::Consumer
|
|
16
16
|
Mumukit::Nuntius::Logger.info "Leaving queue #{queue_name}"
|
17
17
|
ensure
|
18
18
|
channel.close
|
19
|
-
connection.close
|
20
19
|
end
|
21
20
|
end
|
22
21
|
|
@@ -3,9 +3,9 @@ module Mumukit::Nuntius::Publisher
|
|
3
3
|
class << self
|
4
4
|
|
5
5
|
def publish(exchange_name, data, opts={})
|
6
|
-
|
6
|
+
channel, exchange = Mumukit::Nuntius::Connection.start_channel(exchange_name)
|
7
7
|
exchange.publish(data.to_json, opts.merge(persistent: true))
|
8
|
-
|
8
|
+
channel.close
|
9
9
|
end
|
10
10
|
|
11
11
|
def method_missing(name, *args, &block)
|
data/lib/mumukit/nuntius.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mumukit-nuntius
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 6.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Agustin Pina
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-02-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
120
120
|
version: '0'
|
121
121
|
requirements: []
|
122
122
|
rubyforge_project:
|
123
|
-
rubygems_version: 2.
|
123
|
+
rubygems_version: 2.7.6
|
124
124
|
signing_key:
|
125
125
|
specification_version: 4
|
126
126
|
summary: Library for working with rabbit queues
|