multiple_man 0.2.0 → 0.2.1

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
2
  SHA1:
3
- metadata.gz: 9e1c4aa897f1db298c404d9f6d9a511d497f8ca1
4
- data.tar.gz: 68d3af66452856d5683f3dd9893aa77216347bad
3
+ metadata.gz: e7b860f3537f1110bf32aa9ace742b8f2d0651ea
4
+ data.tar.gz: 03cd81f5720b7223df677a225a1ccd95c21892be
5
5
  SHA512:
6
- metadata.gz: fa34e065547d1e52973f77dd36d907054177a36a858311a91b576fed1405a4dc0d3173cf0384a0c600a190ada4a73b11bdd085bc5e487345b8a3ad799c19c621
7
- data.tar.gz: 776d1610bdce6abdcc08af4dd730802ba5b34722ce07d9866acab98a50dcaa357987175d96f7c1b76c6a27a24df13aa2064c61e9a90e4277abda0fd7d541ceb9
6
+ metadata.gz: 9fd8f4562f017be6be225faea4cc2ee96bc2606322cbdf3c21193892a5974e24323a5da05bc6ad9e11ef0c1e1eff83cd08eccea6ed0b6b1d109961d73e4e488d
7
+ data.tar.gz: 0c886d543a4216146680e025d4920370519925c87acf6ffd3ab734a0db032b79f2ac7508d0d14e35ad662762ab3e9a238c014f78608475f28ae512659d40365d
@@ -1,14 +1,18 @@
1
+ require 'bunny'
2
+
1
3
  module MultipleMan
2
4
  class Connection
3
5
  def self.connect
4
6
  MultipleMan.logger.info "Connecting to #{MultipleMan.configuration.connection}"
5
7
  connection = Bunny.new(MultipleMan.configuration.connection)
6
- MultipleMan.logger.info "Starting connection - block #{block_given?}"
7
- connection.start
8
- yield new(connection) if block_given?
9
- ensure
10
- MultipleMan.logger.info "Closing connection"
11
- connection.close
8
+ begin
9
+ MultipleMan.logger.info "Starting connection"
10
+ connection.start
11
+ yield new(connection) if block_given?
12
+ ensure
13
+ MultipleMan.logger.info "Closing connection"
14
+ connection.close
15
+ end
12
16
  end
13
17
 
14
18
  def initialize(connection)
@@ -5,7 +5,7 @@ module MultipleMan
5
5
 
6
6
  class << self
7
7
  def start(connection)
8
- puts "Starting listeners."
8
+ MultipleMan.logger.info "Starting listeners."
9
9
  self.connection = connection
10
10
  ModelSubscriber.subscriptions.each do |subscription|
11
11
  new(subscription).listen
@@ -22,21 +22,21 @@ module MultipleMan
22
22
  attr_accessor :subscription
23
23
 
24
24
  def listen
25
- puts "Listening for #{subscription.klass} with routing key #{subscription.routing_key}."
25
+ MultipleMan.logger.info "Listening for #{subscription.klass} with routing key #{subscription.routing_key}."
26
26
  queue.bind(connection.topic, routing_key: subscription.routing_key).subscribe do |delivery_info, meta_data, payload|
27
27
  process_message(delivery_info, payload)
28
28
  end
29
29
  end
30
30
 
31
31
  def process_message(delivery_info, payload)
32
- puts "Processing message for #{delivery_info.routing_key}."
32
+ MultipleMan.logger.info "Processing message for #{delivery_info.routing_key}."
33
33
  begin
34
34
  operation = delivery_info.routing_key.split(".").last
35
- subscription.send(operation, JSON.parse(payload))
35
+ subscription.send(operation, JSON.parse(payload).with_indifferent_access)
36
36
  rescue Exception => ex
37
- puts " Error - #{ex.message}"
37
+ MultipleMan.logger.error " Error - #{ex.message}"
38
38
  end
39
- puts " Successfully processed!"
39
+ MultipleMan.logger.info " Successfully processed!"
40
40
  end
41
41
 
42
42
  def queue
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiple_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner