multiple_man 1.5.0 → 1.6.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
2
  SHA1:
3
- metadata.gz: 8b0b5340cba015cfbf0a2a43f04283743415bf2f
4
- data.tar.gz: 541a5bc2ba571cc2d915508b6ba12e70c58a9e14
3
+ metadata.gz: c8569fbeb2332b746b624b89ca693b82fafbbbd8
4
+ data.tar.gz: 22546e311063337f0570896f2ed40387547a6135
5
5
  SHA512:
6
- metadata.gz: 3ef57043bd9b127e7418b5f6935ed3589d71919f1a740b4d658a0d04e9025af6d73fb467a5414d6b44cd8a2340f1ff2efe18de6ecf25fa63731506c21dcdfe63
7
- data.tar.gz: 192d47727ed9dd2b881351d9eac3eb2c0fcc66e145ef56f9dcbb07f7b71cbb4257a25e7afbc2a9ac6ebf240424d4c142e3a740877cd0e62bb3aea7da874c81bd
6
+ metadata.gz: 9ca8387c22e2ca8665d4cf90f5e990dea472d7a46b1a448540e8adb01af6d8c759c358c2ca5505e1005a03e49aba257cd5df6fb93d050e0478211881318e3736
7
+ data.tar.gz: 0e022910a4b70baea88d04092bebabbbf4b90a7a34cc34f7c2e1d013d5d85d9e34aca2569eb4bba0e747520da1a4d6e94fd45b36e425575bb3c096db72f257b9
@@ -4,6 +4,8 @@ require 'active_support'
4
4
  module MultipleMan
5
5
  Error = Class.new(StandardError)
6
6
  ConsumerError = Class.new(Error)
7
+ ProducerError = Class.new(Error)
8
+ ConnectionError = Class.new(Error)
7
9
 
8
10
  require 'multiple_man/railtie' if defined?(Rails)
9
11
 
@@ -11,7 +11,8 @@ 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, :exchange_opts
14
+ :queue_name, :prefetch_size, :bunny_opts, :exchange_opts,
15
+ :publisher_confirms
15
16
 
16
17
  attr_writer :logger
17
18
 
@@ -29,6 +30,7 @@ module MultipleMan
29
30
  }
30
31
  self.bunny_opts = {}
31
32
  self.exchange_opts = {}
33
+ self.publisher_confirms = false
32
34
 
33
35
  @subscriber_registry = Subscribers::Registry.new
34
36
  end
@@ -21,7 +21,7 @@ module MultipleMan
21
21
  retry
22
22
  else
23
23
  Thread.current[:multiple_man_exception_retry_count] = 0
24
- raise "MultipleMan::ConnectionError"
24
+ raise ConnectionError, e
25
25
  end
26
26
  end
27
27
 
@@ -29,6 +29,7 @@ module MultipleMan
29
29
  Thread.current.thread_variable_get(:multiple_man_current_channel) || begin
30
30
  channel = connection.create_channel
31
31
  channel_gc.push(channel)
32
+ channel.confirm_select if MultipleMan.configuration.publisher_confirms
32
33
  Thread.current.thread_variable_set(:multiple_man_current_channel, channel)
33
34
 
34
35
  channel
@@ -20,7 +20,8 @@ module MultipleMan
20
20
  end
21
21
  end
22
22
  rescue Exception => ex
23
- MultipleMan.error(ex)
23
+ err = ProducerError.new(reason: ex, payload: records.inspect)
24
+ MultipleMan.error(err, reraise: false)
24
25
  end
25
26
 
26
27
  private
@@ -45,6 +46,5 @@ module MultipleMan
45
46
  yield records
46
47
  end
47
48
  end
48
-
49
49
  end
50
50
  end
@@ -1,3 +1,3 @@
1
1
  module MultipleMan
2
- VERSION = "1.5.0"
2
+ VERSION = "1.6.0"
3
3
  end
@@ -1,6 +1,6 @@
1
1
  require 'spec_helper'
2
2
 
3
- describe MultipleMan::ModelPublisher do
3
+ describe MultipleMan::ModelPublisher do
4
4
  let(:channel_stub) { double(Bunny::Channel, topic: topic_stub)}
5
5
  let(:topic_stub) { double(Bunny::Exchange, publish: nil) }
6
6
 
@@ -35,10 +35,17 @@ describe MultipleMan::ModelPublisher do
35
35
  end
36
36
 
37
37
  it "should call the error handler on error" do
38
- ex = Exception.new("Bad stuff happened")
38
+ records = MockObject.new
39
+ mock_error = MultipleMan::ProducerError.new
40
+ ex = Exception.new("Bad stuff happened")
41
+
39
42
  topic_stub.stub(:publish) { raise ex }
40
- MultipleMan.should_receive(:error).with(ex)
41
- described_class.new(fields: [:foo]).publish(MockObject.new)
43
+ MultipleMan.should_receive(:error).with(mock_error, reraise: false)
44
+ MultipleMan::ProducerError.should_receive(
45
+ :new
46
+ ).with(reason: ex, payload: records.inspect).and_return(mock_error)
47
+
48
+ described_class.new(fields: [:foo]).publish(records)
42
49
  end
43
50
  end
44
51
 
@@ -59,5 +66,4 @@ describe MultipleMan::ModelPublisher do
59
66
  subject.publish(obj)
60
67
  end
61
68
  end
62
-
63
- end
69
+ end
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.5.0
4
+ version: 1.6.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-06-20 00:00:00.000000000 Z
11
+ date: 2017-06-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny