pwwka 0.15.0 → 0.15.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:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e2d3849c6e410b41770f48dcdcd6a3362ffb632c
|
|
4
|
+
data.tar.gz: 79c4b07513148802d9235c3606fcd176dd49ce71
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d69b7df9738dc5d3689158a9114316f2e9405287c6f35bbea725a6f2a77e298276f3a66462abf0366e12ac40b37042f2e75845bddc93a314b7663ede5dbfc0d1
|
|
7
|
+
data.tar.gz: 6d03c19a90c1db1e4bcd334abd23eb9d7d4ffa11ef7cedeb6446598d5099d80c8a2ec1c4e4b731dd477069287cd2865a6a637a7f7f4f7e69d649fee69ea8668c
|
data/Gemfile.lock
CHANGED
|
@@ -13,18 +13,23 @@ module Pwwka
|
|
|
13
13
|
@error_handlers.unshift(message_handler_klass.send(:error_handler))
|
|
14
14
|
end
|
|
15
15
|
@error_handlers.reduce(true) { |keep_going,error_handler|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
keep_going = error_handler.new.handle_error(receiver,queue_name,payload,delivery_info,exception)
|
|
16
|
+
begin
|
|
17
|
+
logf "%{error_handler_class} is being evaluated as part of pwwka's error-handling chain", error_handler_class: error_handler
|
|
19
18
|
if keep_going
|
|
20
|
-
|
|
19
|
+
keep_going = error_handler.new.handle_error(receiver,queue_name,payload,delivery_info,exception)
|
|
20
|
+
if keep_going
|
|
21
|
+
logf "%{error_handler_class} has asked to continue pwwka's error-handling chain", error_handler_class: error_handler
|
|
22
|
+
else
|
|
23
|
+
logf "%{error_handler_class} has halted pwwka's error-handling chain", error_handler_class: error_handler
|
|
24
|
+
end
|
|
21
25
|
else
|
|
22
|
-
logf "%{error_handler_class}
|
|
26
|
+
logf "Skipping %{error_handler_class} as we were asked to abort pwwka's error-handling chain", error_handler_class: error_handler
|
|
23
27
|
end
|
|
24
|
-
|
|
25
|
-
|
|
28
|
+
keep_going
|
|
29
|
+
rescue StandardError => exception
|
|
30
|
+
logf "'%{error_handler_class}' aborting due to unhandled exception '%{exception}'", at: :fatal, error_handler_class: error_handler, exception: exception
|
|
31
|
+
false
|
|
26
32
|
end
|
|
27
|
-
keep_going
|
|
28
33
|
}
|
|
29
34
|
end
|
|
30
35
|
end
|
data/lib/pwwka/version.rb
CHANGED
|
@@ -5,6 +5,19 @@ require_relative "support/integration_test_setup"
|
|
|
5
5
|
require_relative "support/logging_receiver"
|
|
6
6
|
require_relative "support/integration_test_helpers"
|
|
7
7
|
|
|
8
|
+
class PoorlyBehavingErrorHandler < Pwwka::ErrorHandlers::BaseErrorHandler
|
|
9
|
+
def handle_error(receiver,queue_name,payload,delivery_info,exception)
|
|
10
|
+
raise "whoops, do I break everything behind me?"
|
|
11
|
+
keep_going
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
class ErrorHandlerThatWorksFine < Pwwka::ErrorHandlers::BaseErrorHandler
|
|
16
|
+
def handle_error(receiver,queue_name,payload,delivery_info,exception)
|
|
17
|
+
keep_going
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
8
21
|
class EvilPayload
|
|
9
22
|
def to_json
|
|
10
23
|
"This is not JSON by any stretch"
|
|
@@ -167,6 +180,33 @@ describe "receivers with unhandled errors", :integration do
|
|
|
167
180
|
end
|
|
168
181
|
end
|
|
169
182
|
|
|
183
|
+
context "a custom error handler in the pwwka error handling chain throws its own exception" do
|
|
184
|
+
before do
|
|
185
|
+
@testing_setup.make_queue_and_setup_receiver(ExceptionThrowingReceiver,"exception_throwing_receiver_pwwkatesting","#")
|
|
186
|
+
ExceptionThrowingReceiver.reset!
|
|
187
|
+
|
|
188
|
+
Pwwka.configuration.instance_variable_set("@error_handling_chain",
|
|
189
|
+
[
|
|
190
|
+
PoorlyBehavingErrorHandler,
|
|
191
|
+
ErrorHandlerThatWorksFine
|
|
192
|
+
])
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
after do
|
|
196
|
+
Pwwka.configuration.instance_variable_set("@error_handling_chain",nil)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
it "confirms subsequent error handlers do not run when there is an exception earlier in the chain" do
|
|
200
|
+
Pwwka::Transmitter.send_message!({ sample: "payload", has: { deeply: true, nested: 4 }},
|
|
201
|
+
"pwwka.testing.foo")
|
|
202
|
+
|
|
203
|
+
allow_receivers_to_process_queues
|
|
204
|
+
|
|
205
|
+
expect(ExceptionThrowingReceiver.messages_received.size).to eq(1)
|
|
206
|
+
expect(@testing_setup.threads[ExceptionThrowingReceiver].alive?).to eq(true)
|
|
207
|
+
end
|
|
208
|
+
end
|
|
209
|
+
|
|
170
210
|
def setup_receivers(exception_throwing_receiver_klass=ExceptionThrowingReceiver)
|
|
171
211
|
[
|
|
172
212
|
[exception_throwing_receiver_klass, "exception_throwing_receiver_pwwkatesting"],
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
require "spec_helper"
|
|
2
|
+
|
|
3
|
+
describe Pwwka::ErrorHandlers::Chain do
|
|
4
|
+
subject(:chain) { described_class.new(default_handler_chain) }
|
|
5
|
+
|
|
6
|
+
describe "#handle_error" do
|
|
7
|
+
context "when an error handler raises an unhandled exception" do
|
|
8
|
+
let(:default_handler_chain) { [bad_error_handler_klass, good_error_handler_klass] }
|
|
9
|
+
let(:bad_error_handler_klass) { double("bad error handler klass", new: bad_error_handler) }
|
|
10
|
+
let(:bad_error_handler) {
|
|
11
|
+
handler = double("bad error handler")
|
|
12
|
+
allow(handler).to receive(:handle_error).and_raise("unhandled exception in error handler")
|
|
13
|
+
handler
|
|
14
|
+
}
|
|
15
|
+
let(:good_error_handler_klass) { double("good error handler klass") }
|
|
16
|
+
|
|
17
|
+
before { allow(bad_error_handler).to receive(:error_handler).and_raise("Wibble") }
|
|
18
|
+
|
|
19
|
+
it "does not run subsequent error handlers" do
|
|
20
|
+
expect(good_error_handler_klass).to_not receive(:new)
|
|
21
|
+
|
|
22
|
+
chain.handle_error(double,double,double,double,double,double.as_null_object)
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
it "logs exceptions that occur in the error handling chain" do
|
|
26
|
+
allow(chain.logger).to receive(:send).with(any_args)
|
|
27
|
+
expect(chain.logger).to receive(:send).with(:fatal, /aborting due to unhandled exception/)
|
|
28
|
+
|
|
29
|
+
chain.handle_error(double,double,double,double,double,double.as_null_object)
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: pwwka
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.15.
|
|
4
|
+
version: 0.15.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Stitch Fix Engineering
|
|
@@ -15,7 +15,7 @@ authors:
|
|
|
15
15
|
autorequire:
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
|
-
date: 2017-
|
|
18
|
+
date: 2017-12-02 00:00:00.000000000 Z
|
|
19
19
|
dependencies:
|
|
20
20
|
- !ruby/object:Gem::Dependency
|
|
21
21
|
name: bunny
|
|
@@ -237,6 +237,7 @@ files:
|
|
|
237
237
|
- spec/legacy/receiver_spec.rb
|
|
238
238
|
- spec/legacy/send_message_async_job_spec.rb
|
|
239
239
|
- spec/legacy/transmitter_spec.rb
|
|
240
|
+
- spec/lib/pwwka/error_handlers/chain_spec.rb
|
|
240
241
|
- spec/spec_helper.rb
|
|
241
242
|
- spec/support/test_configuration.rb
|
|
242
243
|
- spec/unit/channel_connector_spec.rb
|
|
@@ -267,7 +268,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
267
268
|
version: '0'
|
|
268
269
|
requirements: []
|
|
269
270
|
rubyforge_project:
|
|
270
|
-
rubygems_version: 2.6.
|
|
271
|
+
rubygems_version: 2.6.11
|
|
271
272
|
signing_key:
|
|
272
273
|
specification_version: 4
|
|
273
274
|
summary: Send and receive messages via RabbitMQ
|
|
@@ -283,6 +284,7 @@ test_files:
|
|
|
283
284
|
- spec/legacy/receiver_spec.rb
|
|
284
285
|
- spec/legacy/send_message_async_job_spec.rb
|
|
285
286
|
- spec/legacy/transmitter_spec.rb
|
|
287
|
+
- spec/lib/pwwka/error_handlers/chain_spec.rb
|
|
286
288
|
- spec/spec_helper.rb
|
|
287
289
|
- spec/support/test_configuration.rb
|
|
288
290
|
- spec/unit/channel_connector_spec.rb
|