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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 31d69b0f18fee7cea4bbae540c619fcb88f06273
4
- data.tar.gz: be46f1494c1ba501cf17762b304bde1eab2b905b
2
+ SHA256:
3
+ metadata.gz: 5b704fba179d7c036aa3ad060ee1e3251decbe830e83ebe9aff02ad6b2b2bdb5
4
+ data.tar.gz: f1c22a0ad81c448f90fb84b54d9f40b1d671a246be68391b73b20be703554ac3
5
5
  SHA512:
6
- metadata.gz: f37cd6a7dcbe3df462524786d05cd57d3837a51ef89f29ff40406dd249793ea6e1de18040c1df3ee9d03389ad399d4230169ec1605253d2c09ff2cbdd197545b
7
- data.tar.gz: 5ab6a4ceafcf7e2e7d64006bade64be9db3e3bb30493d012f468e82ed219a6291f650f8b03d059cb115be60a1ba6596c5b3d043b8928dbea4db7a6475b05ec91
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 start(exchange_name)
11
- connection = Bunny.new(host: config[:host], user: config[:user], password: config[:password])
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
- [connection, channel, exchange]
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
- connection, channel, exchange = Mumukit::Nuntius::Connection.start(exchange_name)
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
 
@@ -5,5 +5,8 @@ module Mumukit::Nuntius::NotificationMode
5
5
 
6
6
  def notify_event!(*)
7
7
  end
8
+
9
+ def establish_connection
10
+ end
8
11
  end
9
12
  end
@@ -7,5 +7,9 @@ module Mumukit::Nuntius::NotificationMode
7
7
  def notify_event!(type, data)
8
8
  Mumukit::Nuntius::EventPublisher.publish type, data
9
9
  end
10
+
11
+ def establish_connection
12
+ Mumukit::Nuntius::Connection.establish_connection
13
+ end
10
14
  end
11
15
  end
@@ -3,9 +3,9 @@ module Mumukit::Nuntius::Publisher
3
3
  class << self
4
4
 
5
5
  def publish(exchange_name, data, opts={})
6
- connection, channel, exchange = Mumukit::Nuntius::Connection.start(exchange_name)
6
+ channel, exchange = Mumukit::Nuntius::Connection.start_channel(exchange_name)
7
7
  exchange.publish(data.to_json, opts.merge(persistent: true))
8
- connection.close
8
+ channel.close
9
9
  end
10
10
 
11
11
  def method_missing(name, *args, &block)
@@ -1,5 +1,5 @@
1
1
  module Mumukit
2
2
  module Nuntius
3
- VERSION = '5.0.0'
3
+ VERSION = '6.0.0'
4
4
  end
5
5
  end
@@ -54,6 +54,10 @@ module Mumukit
54
54
  notification_mode.notify_event! type, event
55
55
  end
56
56
 
57
+ def self.establish_connection
58
+ notification_mode.establish_connection
59
+ end
60
+
57
61
  private
58
62
 
59
63
  def self.notification_mode
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: 5.0.0
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: 2017-04-28 00:00:00.000000000 Z
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.4.5
123
+ rubygems_version: 2.7.6
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Library for working with rabbit queues