lapine 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lapine/consumer/config.rb +1 -1
- data/lib/lapine/consumer/dispatcher.rb +3 -2
- data/lib/lapine/version.rb +1 -1
- data/spec/lib/lapine/consumer/dispatcher_spec.rb +29 -12
- data/spec/spec_helper.rb +1 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d72d9ebaaaca0995cdf88aa8a2741f95b17d7514
|
4
|
+
data.tar.gz: 113b59cf6d8f411b983cd1202da0c8b557b78d94
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fb7291e77fb106921cbd0c9036de7fee053cb6ed396d614e2d0f88d6be9bc2f9cc804f4eca77896563288708bf8da344890f28fb052a5b7a9bad9f7868d2ffc
|
7
|
+
data.tar.gz: 347b60824f615d3329b210bd7d83d2b7eeb97c86ad21d159ac6fe18464df2e35a93b045fdb49d9ad16220b34d6b36d248267de45939b6cf24d8895cc3f8e7b45
|
@@ -5,8 +5,9 @@ module Lapine
|
|
5
5
|
module Consumer
|
6
6
|
class Dispatcher
|
7
7
|
class DefaultErrorHandler
|
8
|
+
|
8
9
|
def call(e, data)
|
9
|
-
|
10
|
+
$stderr.puts "Lapine::Dispatcher unable to dispatch, #{e.message}, data: #{data}"
|
10
11
|
end
|
11
12
|
end
|
12
13
|
|
@@ -47,7 +48,7 @@ module Lapine
|
|
47
48
|
ret = yield
|
48
49
|
time_end = Time.now
|
49
50
|
duration = (time_end - time) * 1000
|
50
|
-
logger.info
|
51
|
+
logger.info "Processing rabbit message handler:#{delegate_class.name} duration(ms):#{duration} payload:#{json.inspect}"
|
51
52
|
ret
|
52
53
|
end
|
53
54
|
|
data/lib/lapine/version.rb
CHANGED
@@ -12,10 +12,8 @@ RSpec.describe Lapine::Consumer::Dispatcher do
|
|
12
12
|
|
13
13
|
let(:caught_errors) { [] }
|
14
14
|
|
15
|
-
|
16
|
-
Lapine::Consumer::Dispatcher.error_handler =
|
17
|
-
caught_errors << [error, data]
|
18
|
-
}
|
15
|
+
after do
|
16
|
+
Lapine::Consumer::Dispatcher.error_handler = nil
|
19
17
|
end
|
20
18
|
|
21
19
|
describe "#delegation" do
|
@@ -43,23 +41,42 @@ RSpec.describe Lapine::Consumer::Dispatcher do
|
|
43
41
|
end
|
44
42
|
|
45
43
|
describe 'error cases' do
|
46
|
-
context 'with invalid json' do
|
47
|
-
let(:json) { 'oh boy I am not actually JSON' }
|
48
44
|
|
49
|
-
|
50
|
-
|
51
|
-
|
45
|
+
context 'custom error handler' do
|
46
|
+
before do
|
47
|
+
Lapine::Consumer::Dispatcher.error_handler = ->(error, data) {
|
48
|
+
caught_errors << [error, data]
|
49
|
+
}
|
50
|
+
end
|
51
|
+
context 'with invalid json' do
|
52
|
+
let(:json) { 'oh boy I am not actually JSON' }
|
53
|
+
|
54
|
+
it 'notifies the error handler with the raw payload' do
|
55
|
+
dispatcher.dispatch
|
56
|
+
expect(caught_errors).to include([an_instance_of(Oj::ParseError), json])
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
context 'with any other error' do
|
61
|
+
before { allow(dispatcher).to receive(:do_dispatch).and_raise(ArgumentError) }
|
62
|
+
|
63
|
+
it 'notifies error handler with the parsed json' do
|
64
|
+
dispatcher.dispatch
|
65
|
+
expect(caught_errors).to include([an_instance_of(ArgumentError), hash])
|
66
|
+
end
|
52
67
|
end
|
53
68
|
end
|
54
69
|
|
55
|
-
context '
|
70
|
+
context 'default error handler' do
|
56
71
|
before { allow(dispatcher).to receive(:do_dispatch).and_raise(ArgumentError) }
|
57
72
|
|
58
|
-
it 'notifies error handler
|
73
|
+
it 'notifies default error handler' do
|
74
|
+
expect($stderr).to receive(:puts)
|
59
75
|
dispatcher.dispatch
|
60
|
-
expect(caught_errors).to include([an_instance_of(ArgumentError), hash])
|
61
76
|
end
|
62
77
|
end
|
78
|
+
|
79
|
+
|
63
80
|
end
|
64
81
|
end
|
65
82
|
end
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lapine
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Saxby
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-12-
|
12
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: amqp
|