multiple_man 1.2.0 → 1.3.0

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
  SHA1:
3
- metadata.gz: ceeee8dc76c654ed8daff0e4d6ddcd7cef43e585
4
- data.tar.gz: 427cf647712f72870f9ac719e256f745b7cdd42f
3
+ metadata.gz: d92ba04f6fe9404dd98ce8c89addb6bbd11a3011
4
+ data.tar.gz: f5cd19e11c8cb204e0be5da36c0ac58fbeb6dad0
5
5
  SHA512:
6
- metadata.gz: d41e89d79310577776ce03c5d0a78b330390825ec44df5f7f33d3944403a46ee3ef479f202709a1322e396d266ada39dd5ff22893e8907e9e9988c453822e9cc
7
- data.tar.gz: 18d869319b8565e4a7092d8708757671b849c3b7a234e99a71a5befa6e353037222d1782664d108beaf1c45fbddd05839143a55faca0138ef773480d2ce9e91e
6
+ metadata.gz: 3718e17f9e5fc958ef18d30d870319569a909508980de9922dfdb076a304390fc2c6e2caaa13ce32555579effa937c2fff8ad12f18a2b9e1b3533a4fb423ac96
7
+ data.tar.gz: fe756d81f72831b3db89064ed7e0f3749823bf47a76d210f53c0f05c8da8b4bf782f2e6e611e3b1fcc59a327a561f9da86b1804fb5a82d8e376baf7d7b0751c6
data/README.md CHANGED
@@ -58,6 +58,11 @@ calling MultipleMan.configure like so:
58
58
  tls_ca_certificates: ['/usr/lib/ssl/certs/cacert.pem']
59
59
  }
60
60
 
61
+ # Add opts that are used when creating the exchange
62
+ config.exchange_opts = {
63
+ durable: true
64
+ }
65
+
61
66
  # Where you want to log errors to. Should be an instance of Logger
62
67
  # Defaults to the Rails logger (for Rails) or STDOUT otherwise.
63
68
  config.logger = Logger.new(STDOUT)
@@ -11,7 +11,7 @@ module MultipleMan
11
11
  attr_reader :subscriber_registry
12
12
  attr_accessor :topic_name, :app_name, :connection, :enabled, :error_handler,
13
13
  :worker_concurrency, :reraise_errors, :connection_recovery,
14
- :queue_name, :prefetch_size, :bunny_opts
14
+ :queue_name, :prefetch_size, :bunny_opts, :exchange_opts
15
15
 
16
16
  attr_writer :logger
17
17
 
@@ -28,6 +28,7 @@ module MultipleMan
28
28
  max_retries: 5
29
29
  }
30
30
  self.bunny_opts = {}
31
+ self.exchange_opts = {}
31
32
 
32
33
  @subscriber_registry = Subscribers::Registry.new
33
34
  end
@@ -76,7 +76,7 @@ module MultipleMan
76
76
 
77
77
  def initialize(channel)
78
78
  self.channel = channel
79
- self.topic = channel.topic(topic_name)
79
+ self.topic = channel.topic(topic_name, MultipleMan.configuration.exchange_opts)
80
80
  end
81
81
 
82
82
  def topic_name
@@ -42,7 +42,7 @@ module MultipleMan
42
42
  begin
43
43
  raise ConsumerError
44
44
  rescue => wrapped_ex
45
- MultipleMan.logger.debug "\tError #{wrapped_ex.message} \n#{wrapped_ex.backtrace}"
45
+ MultipleMan.logger.debug "\t#{wrapped_ex.class} #{wrapped_ex.cause.message} \n#{wrapped_ex.cause.backtrace}"
46
46
  MultipleMan.error(wrapped_ex, reraise: false, payload: message, delivery_info: delivery_info)
47
47
  queue.channel.nack(delivery_info.delivery_tag)
48
48
  end
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "1.2.0"
2
+ VERSION = "1.3.0"
3
3
  end
@@ -10,10 +10,12 @@ describe MultipleMan::Connection do
10
10
  MultipleMan::Connection.reset!
11
11
  end
12
12
 
13
- it "should open a connection and a channel" do
13
+ it "should open a connection and a channel with opts" do
14
+ MultipleMan.configuration.exchange_opts = {durable: true, another: 'opt'}
15
+
14
16
  MultipleMan::Connection.should_receive(:connection).and_return(mock_bunny)
15
17
  mock_bunny.should_receive(:create_channel).once.and_return(mock_channel)
16
- expect(mock_channel).to receive(:topic).with(MultipleMan.configuration.topic_name)
18
+ expect(mock_channel).to receive(:topic).with(MultipleMan.configuration.topic_name, durable: true, another: 'opt')
17
19
 
18
20
  described_class.connect { }
19
21
  end
@@ -89,17 +89,22 @@ describe MultipleMan::Consumers::General do
89
89
 
90
90
  it 'wraps errors in ConsumerError' do
91
91
  channel = double(Bunny::Channel)
92
- queue = double(Bunny::Queue, channel: channel).as_null_object
92
+ queue = double(Bunny::Queue, channel: channel).as_null_object
93
+ error = ArgumentError.new("undefined method `foo' for nil:NilClass")
94
+ error.set_backtrace(["file.rb:1 'foo'"])
93
95
 
94
96
  delivery_info = OpenStruct.new(routing_key: "multiple_man.SomeClass.create")
95
97
  payload = '{"a":1,"b":2}'
96
98
  allow(queue).to receive(:subscribe).and_yield(delivery_info, double(:meta), payload)
97
99
 
98
100
  subscriber = listener1.new
99
- allow(subscriber).to receive(:create).and_raise('anything')
101
+ allow(subscriber).to receive(:create).and_raise(error)
100
102
 
101
103
  allow(channel).to receive(:nack)
102
104
 
105
+ expect(MultipleMan.logger).to receive(:debug).with('Starting listeners.')
106
+ expect(MultipleMan.logger).to receive(:debug).with('Processing message for multiple_man.SomeClass.create.')
107
+ expect(MultipleMan.logger).to receive(:debug).with("\tMultipleMan::ConsumerError #{error.message} \n#{error.backtrace}")
103
108
  expect(MultipleMan).to receive(:error).with(kind_of(MultipleMan::ConsumerError), kind_of(Hash))
104
109
  subject = described_class.new(subscribers:[subscriber], queue: queue, topic: 'some-topic')
105
110
  subject.listen
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: multiple_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.0
4
+ version: 1.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Brunner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-17 00:00:00.000000000 Z
11
+ date: 2017-05-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny