rabbit_feed 2.3.9 → 2.3.10

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: d56c7c94bb76a6ee1a8ca77a5666d89dcc26fb30
4
- data.tar.gz: 33e7a05722fe28047edb67132cd3902404c622ab
3
+ metadata.gz: 5b141fd052af473176629d66db5d86963fe4c403
4
+ data.tar.gz: 38f362690f98f836cab2caef5fad99a4a8bca27a
5
5
  SHA512:
6
- metadata.gz: 10237bc7ef9d916b0bef1d389972063c388e41e3a76f875f494c219f37b431c45a3d63fb364bbdf735d08a68676979b49bc4c3618fb57050941bf21e650d9445
7
- data.tar.gz: dc0bd78e8d2c5b6cf709650ca38a0ad90cc56fb00677eca97eac3f5dc27276a4619e459922855784906d4e7f09124430c3f082e4b20520c839c71ddb8f89e111
6
+ metadata.gz: 88e147ca7b35bf34bb703b9041eb94cbe9d4042e38df8742c55fbea6091c3e2575a64e04214ebe9010a42ae514d60fc1f2c84e6b9a46a4ad6190889722c6141a
7
+ data.tar.gz: 30e4acb794167f0d505b65a3f64363f8b66f88ed6ddb77fd1d1b61aed121f44d355f5fe92576880029bc39f364dbbe26c7b378df3f478f4894f861ed0713a34e
data/README.md CHANGED
@@ -38,22 +38,23 @@ Sample:
38
38
 
39
39
  Configuration options that can be specified are:
40
40
 
41
- | Name | Use |
42
- | ---- | --- |
43
- | `host` | Hostname or IP of the RabbitMQ server |
44
- | `hosts` | Array of hostnames or IPs of a RabbitMQ cluster |
45
- | `port` | The port to use on the RabbitMQ server |
46
- | `user` | The user to authenticate with the RabbitMQ server |
47
- | `password` | The password to authenticate with the RabbitMQ server |
48
- | `application` | The name of the application - used for routing events to the specified consumers |
49
- | `environment` | The environment of the application - used for routing events to the specified consumers |
50
- | `exchange` | The name of the RabbitMQ exchange to which events are published |
51
- | `heartbeat` | The interval at which to send heartbeats to the RabbitMQ server (in seconds) |
52
- | `connect_timeout` | The timeout (in seconds) for connecting to the RabbitMQ server |
53
- | `network_recovery_interval` | Recovery interval (in seconds) periodic network recovery will use |
54
- | `auto_delete_queue` | If true, any queues created will auto-delete upon disconnect |
55
- | `auto_delete_exchange` | If true, any exchanges created will auto-delete upon disconnect |
56
- | `route_prefix_extension` | If set, the routing key/queue of the exchange will become env.`route_prefix_extension`.application.event |
41
+ | Name | Use |
42
+ | ---- | --- |
43
+ | `host` | Hostname or IP of the RabbitMQ server |
44
+ | `hosts` | Array of hostnames or IPs of a RabbitMQ cluster |
45
+ | `port` | The port to use on the RabbitMQ server |
46
+ | `user` | The user to authenticate with the RabbitMQ server |
47
+ | `password` | The password to authenticate with the RabbitMQ server |
48
+ | `application` | The name of the application - used for routing events to the specified consumers |
49
+ | `environment` | The environment of the application - used for routing events to the specified consumers |
50
+ | `exchange` | The name of the RabbitMQ exchange to which events are published |
51
+ | `heartbeat` | The interval at which to send heartbeats to the RabbitMQ server (in seconds) |
52
+ | `connect_timeout` | The timeout (in seconds) for connecting to the RabbitMQ server |
53
+ | `network_recovery_interval` | Recovery interval (in seconds) periodic network recovery will use |
54
+ | `auto_delete_queue` | If true, any queues created will auto-delete upon disconnect |
55
+ | `auto_delete_exchange` | If true, any exchanges created will auto-delete upon disconnect |
56
+ | `route_prefix_extension` | If set, the routing key/queue of the exchange will become env.`route_prefix_extension`.application.event |
57
+ | `consumer_exit_after_fail` | If set, consumer will stop consuming as soon as it fails to process an event. By default, it will continue to consume and log the error(s) |
57
58
 
58
59
  ### Initialisation
59
60
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- rabbit_feed (2.3.9)
4
+ rabbit_feed (2.3.10)
5
5
  activemodel (>= 3.2.0, < 5.0.0)
6
6
  activesupport (>= 3.2.0, < 5.0.0)
7
7
  avro (>= 1.5.4, < 1.8.0)
@@ -11,10 +11,10 @@ PATH
11
11
  GEM
12
12
  remote: https://rubygems.org/
13
13
  specs:
14
- activemodel (4.2.5)
15
- activesupport (= 4.2.5)
14
+ activemodel (4.2.5.1)
15
+ activesupport (= 4.2.5.1)
16
16
  builder (~> 3.1)
17
- activesupport (4.2.5)
17
+ activesupport (4.2.5.1)
18
18
  i18n (~> 0.7)
19
19
  json (~> 1.7, >= 1.7.7)
20
20
  minitest (~> 5.1)
@@ -29,7 +29,7 @@ GEM
29
29
  diff-lcs (1.2.5)
30
30
  i18n (0.7.0)
31
31
  json (1.8.3)
32
- minitest (5.8.3)
32
+ minitest (5.8.4)
33
33
  multi_json (1.11.2)
34
34
  pidfile (0.3.0)
35
35
  rake (10.4.2)
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ../../
3
3
  specs:
4
- rabbit_feed (2.3.9)
4
+ rabbit_feed (2.3.10)
5
5
  activemodel (>= 3.2.0, < 5.0.0)
6
6
  activesupport (>= 3.2.0, < 5.0.0)
7
7
  avro (>= 1.5.4, < 1.8.0)
@@ -3,7 +3,8 @@ module RabbitFeed
3
3
  include ActiveModel::Validations
4
4
 
5
5
  attr_reader :host, :hosts, :port, :user, :password, :application, :environment, :exchange, :heartbeat,
6
- :connect_timeout, :network_recovery_interval, :auto_delete_queue, :auto_delete_exchange
6
+ :connect_timeout, :network_recovery_interval, :auto_delete_queue, :auto_delete_exchange,
7
+ :consumer_exit_after_fail
7
8
  validates_presence_of :application, :environment, :exchange
8
9
 
9
10
  def initialize options
@@ -23,6 +24,7 @@ module RabbitFeed
23
24
  @application = options[:application]
24
25
  @environment = options[:environment]
25
26
  @route_prefix_extension = options[:route_prefix_extension]
27
+ @consumer_exit_after_fail = options[:consumer_exit_after_fail] || false
26
28
  validate!
27
29
  end
28
30
 
@@ -79,6 +79,7 @@ module RabbitFeed
79
79
  acknowledge delivery_info
80
80
  rescue => e
81
81
  handle_processing_exception delivery_info, e
82
+ exit(1) if RabbitFeed.configuration.consumer_exit_after_fail
82
83
  end
83
84
  end
84
85
 
@@ -1,3 +1,3 @@
1
1
  module RabbitFeed
2
- VERSION = '2.3.9'
2
+ VERSION = '2.3.10'
3
3
  end
@@ -154,6 +154,7 @@ module RabbitFeed
154
154
  its(:connect_timeout) { should be_nil }
155
155
  its(:auto_delete_queue) { should be_falsey }
156
156
  its(:auto_delete_exchange) { should be_falsey }
157
+ its(:consumer_exit_after_fail) { should be_falsey }
157
158
  end
158
159
 
159
160
  context 'with provided options' do
@@ -172,6 +173,7 @@ module RabbitFeed
172
173
  network_recovery_interval: 2,
173
174
  auto_delete_queue: 'true',
174
175
  auto_delete_exchange: 'false',
176
+ consumer_exit_after_fail: 'true'
175
177
  }
176
178
  end
177
179
 
@@ -188,6 +190,7 @@ module RabbitFeed
188
190
  its(:network_recovery_interval) { should eq 2 }
189
191
  its(:auto_delete_queue) { should be_truthy }
190
192
  its(:auto_delete_exchange) { should be_truthy }
193
+ its(:consumer_exit_after_fail) { should be_truthy }
191
194
  end
192
195
 
193
196
  context 'with empty options' do
@@ -79,46 +79,61 @@ module RabbitFeed
79
79
 
80
80
  context 'when an exception is raised' do
81
81
 
82
- context 'when Airbrake is defined' do
83
- after { Object.send(:remove_const, ('Airbrake').to_sym) rescue NameError }
82
+ context 'when consumer_exit_after_fail is true' do
83
+ before { allow(RabbitFeed.configuration).to receive(:consumer_exit_after_fail).and_return(true) }
84
84
 
85
- context 'when the version is lower than 5' do
86
- before do
87
- module ::Airbrake
88
- VERSION = '4.0.0'
85
+ it 'exits the application' do
86
+ expect_any_instance_of(described_class).to receive(:exit).with(1)
87
+ subject.consume { raise 'Consuming time' }
88
+ end
89
+ end
90
+
91
+
92
+ context 'when consumer_exit_after_fail is false' do
93
+ before { allow(RabbitFeed.configuration).to receive(:consumer_exit_after_fail).and_return(false) }
94
+
95
+ context 'when Airbrake is defined' do
96
+ after { Object.send(:remove_const, ('Airbrake').to_sym) rescue NameError }
97
+
98
+ context 'when the version is lower than 5' do
99
+ before do
100
+ module ::Airbrake
101
+ VERSION = '4.0.0'
102
+ end
103
+ allow(Airbrake).to receive(:configuration).and_return(airbrake_configuration)
89
104
  end
90
- allow(Airbrake).to receive(:configuration).and_return(airbrake_configuration)
91
- end
92
105
 
93
- context 'and the Airbrake configuration is public' do
94
- let(:airbrake_configuration) { double(:airbrake_configuration, public?: true) }
106
+ context 'and the Airbrake configuration is public' do
107
+ let(:airbrake_configuration) { double(:airbrake_configuration, public?: true) }
95
108
 
96
- it 'notifies airbrake' do
97
- expect(Airbrake).to receive(:notify_or_ignore).with(an_instance_of RuntimeError)
109
+ it 'notifies airbrake' do
110
+ expect(Airbrake).to receive(:notify_or_ignore).with(an_instance_of RuntimeError)
98
111
 
99
- expect{ subject.consume { raise 'Consuming time' } }.not_to raise_error
112
+ expect{ subject.consume { raise 'Consuming time' } }.not_to raise_error
113
+ end
100
114
  end
101
115
  end
102
- end
103
116
 
104
- context 'when the version is greater than 4' do
105
- before do
106
- module ::Airbrake
107
- AIRBRAKE_VERSION = '5.0.0'
117
+ context 'when the version is greater than 4' do
118
+ before do
119
+ module ::Airbrake
120
+ AIRBRAKE_VERSION = '5.0.0'
121
+ end
108
122
  end
109
- end
110
123
 
111
- it 'notifies airbrake' do
112
- expect(Airbrake).to receive(:notify).with(an_instance_of RuntimeError)
113
- expect{ subject.consume { raise 'Consuming time' } }.not_to raise_error
124
+ it 'notifies airbrake' do
125
+ expect(Airbrake).to receive(:notify).with(an_instance_of RuntimeError)
126
+ expect{ subject.consume { raise 'Consuming time' } }.not_to raise_error
127
+ end
114
128
  end
115
129
  end
116
- end
117
130
 
118
- it 'negatively acknowledges the message' do
119
- expect(bunny_channel).to receive(:nack)
120
- subject.consume { raise 'Consuming time' }
131
+ it 'negatively acknowledges the message' do
132
+ expect(bunny_channel).to receive(:nack)
133
+ subject.consume { raise 'Consuming time' }
134
+ end
121
135
  end
136
+
122
137
  end
123
138
  end
124
139
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rabbit_feed
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.9
4
+ version: 2.3.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Simply Business
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-04 00:00:00.000000000 Z
11
+ date: 2016-02-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny