dispatch-rider 1.6.0 → 1.6.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 +4 -4
- data/CHANGELOG.md +32 -6
- data/README.md +7 -1
- data/lib/dispatch-rider.rb +4 -0
- data/lib/dispatch-rider/configuration.rb +1 -1
- data/lib/dispatch-rider/demultiplexer.rb +5 -1
- data/lib/dispatch-rider/logging/json_formatter.rb +16 -10
- data/lib/dispatch-rider/logging/lifecycle_logger.rb +1 -1
- data/lib/dispatch-rider/runner.rb +1 -1
- data/lib/dispatch-rider/version.rb +1 -1
- data/spec/integration/logging_spec.rb +127 -0
- data/spec/lib/dispatch-rider/demultiplexer_spec.rb +0 -1
- data/spec/lib/dispatch-rider/dispatcher_spec.rb +9 -5
- data/spec/lib/dispatch-rider/logging/json_formatter_spec.rb +1 -1
- data/spec/lib/dispatch-rider/runner_spec.rb +4 -0
- data/spec/lib/dispatch-rider/subscriber_spec.rb +16 -8
- data/spec/spec_helper.rb +11 -2
- data/spec/support/crashing_handler.rb +5 -0
- data/spec/support/integration_support.rb +33 -0
- data/spec/support/null_logger.rb +9 -0
- data/spec/support/sample_handler.rb +5 -0
- metadata +12 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 20ecab8e18af62e4795b431f0860148f5929277c
|
4
|
+
data.tar.gz: b87e0c608b4ee99a1e85279bf9d42afc5b4e8b53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e645f3c4257d14f8d17e1402ec5ef73ceee737b380ffa531391a010ad28e11fba30baa806af34d1d21f518583fd6bc44651fc65e5bc36a7f698f50c4edc1158
|
7
|
+
data.tar.gz: 8aa77e404a4caa1680def056db848c6c124c1e1ee935278770b9a35c8e278100a23c5b347b80c2bdadc5c62c3e2b8a494b8f2f5850af531abc46299b824811ea
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,37 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v1.6.0](https://github.com/payrollhero/dispatch-rider/tree/v1.6.0) (2015-06-20)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/payrollhero/dispatch-rider/compare/v1.5.3...v1.6.0)
|
6
|
+
|
7
|
+
**Closed issues:**
|
8
|
+
|
9
|
+
- ActiveJob Support [\#50](https://github.com/payrollhero/dispatch-rider/issues/50)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Adding "long polling" to filesystem queue driver [\#64](https://github.com/payrollhero/dispatch-rider/pull/64) ([piotrb](https://github.com/piotrb))
|
14
|
+
|
15
|
+
- Rspec upgrade [\#63](https://github.com/payrollhero/dispatch-rider/pull/63) ([piotrb](https://github.com/piotrb))
|
16
|
+
|
17
|
+
- Add JSON log formatter [\#62](https://github.com/payrollhero/dispatch-rider/pull/62) ([mykola-kyryk](https://github.com/mykola-kyryk))
|
18
|
+
|
19
|
+
- Extract logging from Demultiplexer into a separate module. Add log fo… [\#61](https://github.com/payrollhero/dispatch-rider/pull/61) ([mykola-kyryk](https://github.com/mykola-kyryk))
|
20
|
+
|
21
|
+
## [v1.5.3](https://github.com/payrollhero/dispatch-rider/tree/v1.5.3) (2015-05-21)
|
22
|
+
|
23
|
+
[Full Changelog](https://github.com/payrollhero/dispatch-rider/compare/v1.4.2...v1.5.3)
|
24
|
+
|
25
|
+
**Merged pull requests:**
|
26
|
+
|
27
|
+
- Allow setting of message guid [\#59](https://github.com/payrollhero/dispatch-rider/pull/59) ([more-ron](https://github.com/more-ron))
|
28
|
+
|
29
|
+
- Make the overriden function "publish to channel" be the only thing overriden [\#58](https://github.com/payrollhero/dispatch-rider/pull/58) ([more-ron](https://github.com/more-ron))
|
30
|
+
|
31
|
+
- Add publishing callbacks [\#57](https://github.com/payrollhero/dispatch-rider/pull/57) ([more-ron](https://github.com/more-ron))
|
32
|
+
|
33
|
+
- Updating rspec and some of the depracations [\#56](https://github.com/payrollhero/dispatch-rider/pull/56) ([piotrb](https://github.com/piotrb))
|
34
|
+
|
3
35
|
## [v1.4.2](https://github.com/payrollhero/dispatch-rider/tree/v1.4.2) (2015-04-10)
|
4
36
|
|
5
37
|
[Full Changelog](https://github.com/payrollhero/dispatch-rider/compare/v1.4.1...v1.4.2)
|
@@ -266,8 +298,6 @@
|
|
266
298
|
|
267
299
|
- Added process naming to dispatcher. [\#23](https://github.com/payrollhero/dispatch-rider/pull/23) ([link664](https://github.com/link664))
|
268
300
|
|
269
|
-
- Fail job after running error handler. [\#27](https://github.com/payrollhero/dispatch-rider/pull/27) ([link664](https://github.com/link664))
|
270
|
-
|
271
301
|
## [v0.0.5](https://github.com/payrollhero/dispatch-rider/tree/v0.0.5) (2013-08-20)
|
272
302
|
|
273
303
|
[Full Changelog](https://github.com/payrollhero/dispatch-rider/compare/2013-06-06-13-08-PST...v0.0.5)
|
@@ -314,10 +344,6 @@
|
|
314
344
|
|
315
345
|
- Fix double serialize on file system bug [\#15](https://github.com/payrollhero/dispatch-rider/pull/15) ([more-ron](https://github.com/more-ron))
|
316
346
|
|
317
|
-
- Add publisher configure method [\#16](https://github.com/payrollhero/dispatch-rider/pull/16) ([more-ron](https://github.com/more-ron))
|
318
|
-
|
319
|
-
- Initial implementation of hash based configuration to satisfy issue \#10 [\#11](https://github.com/payrollhero/dispatch-rider/pull/11) ([jimbomt](https://github.com/jimbomt))
|
320
|
-
|
321
347
|
## [2013-05-28-15-13+08-00](https://github.com/payrollhero/dispatch-rider/tree/2013-05-28-15-13+08-00) (2013-05-28)
|
322
348
|
|
323
349
|
[Full Changelog](https://github.com/payrollhero/dispatch-rider/compare/2013-05-28...2013-05-28-15-13+08-00)
|
data/README.md
CHANGED
@@ -212,6 +212,12 @@ DispatchRider.config do |config|
|
|
212
212
|
end
|
213
213
|
|
214
214
|
config.logger = Rails.logger
|
215
|
+
# Log Formatter
|
216
|
+
# Text Formatter (default)
|
217
|
+
# config.log_formatter = DispatchRider::Logging::TextFormatter.new
|
218
|
+
# JSON Formatter
|
219
|
+
# config.log_formatter = DispatchRider::Logging::JsonFormatter.new
|
220
|
+
|
215
221
|
config.default_retry_timeout = 300
|
216
222
|
|
217
223
|
config.error_handler = DispatchRider::DefaultErrorHandler # an object that responds to .call(message, exception)
|
@@ -226,7 +232,7 @@ end
|
|
226
232
|
Options:
|
227
233
|
|
228
234
|
* `logger` : what logger to use to send messages to (responds to the standard ruby Logger protocol), defaults to a new Logger sending messages to STDERR
|
229
|
-
|
235
|
+
* `log_formatter` : what log formatter to use with logger, defaults to DispatchRider::Logging::TextFormatter.new
|
230
236
|
|
231
237
|
### Callbacks
|
232
238
|
|
data/lib/dispatch-rider.rb
CHANGED
@@ -14,7 +14,7 @@ module DispatchRider
|
|
14
14
|
@logger = Logger.new(STDERR)
|
15
15
|
@debug = false
|
16
16
|
|
17
|
-
@callbacks.around(:
|
17
|
+
@callbacks.around(:dispatch_message) do |job, message|
|
18
18
|
Logging::LifecycleLogger.wrap_handling(message) do
|
19
19
|
job.call
|
20
20
|
end
|
@@ -55,13 +55,17 @@ module DispatchRider
|
|
55
55
|
|
56
56
|
def do_loop
|
57
57
|
catch(:done) do
|
58
|
-
|
58
|
+
while keep_going?
|
59
59
|
throw :done unless @continue
|
60
60
|
yield
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
64
|
|
65
|
+
def keep_going?
|
66
|
+
true
|
67
|
+
end
|
68
|
+
|
65
69
|
def handle_next_queue_item
|
66
70
|
queue.pop do |message|
|
67
71
|
dispatch_message(message)
|
@@ -34,21 +34,27 @@ module DispatchRider
|
|
34
34
|
# @return [String] JSON representation of the log item
|
35
35
|
def format_handling(kind, message, exception: nil, duration: nil)
|
36
36
|
as_json do
|
37
|
-
case kind
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
fragment = case kind
|
38
|
+
when :start
|
39
|
+
message_info_fragment(message)
|
40
|
+
when :success
|
41
|
+
message_info_fragment(message)
|
42
|
+
when :fail
|
43
|
+
exception_info_fragment(message, exception)
|
44
|
+
when :complete
|
45
|
+
duration_fragment = { duration: format_duration(duration) }
|
46
|
+
message_info_fragment(message).merge duration_fragment
|
47
|
+
end
|
48
|
+
{ phase: kind }.merge fragment
|
47
49
|
end
|
48
50
|
end
|
49
51
|
|
50
52
|
private
|
51
53
|
|
54
|
+
def format_duration(duration)
|
55
|
+
duration
|
56
|
+
end
|
57
|
+
|
52
58
|
def as_json
|
53
59
|
JSON.generate yield
|
54
60
|
end
|
@@ -0,0 +1,127 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe "Logging" do
|
4
|
+
let(:publisher) { setup_publisher }
|
5
|
+
let(:subscriber) { setup_subscriber }
|
6
|
+
|
7
|
+
let(:mock_logger_class) do
|
8
|
+
Class.new {
|
9
|
+
def initialize
|
10
|
+
@log = []
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :log
|
14
|
+
|
15
|
+
def info(message)
|
16
|
+
@log << { level: :info, message: message }
|
17
|
+
end
|
18
|
+
|
19
|
+
def error(message)
|
20
|
+
@log << { level: :error, message: message }
|
21
|
+
end
|
22
|
+
}
|
23
|
+
end
|
24
|
+
|
25
|
+
let(:mock_logger) { mock_logger_class.new }
|
26
|
+
|
27
|
+
before do
|
28
|
+
purge_test_queue
|
29
|
+
DispatchRider.config.log_formatter = DispatchRider::Logging::JsonFormatter.new
|
30
|
+
DispatchRider.config.logger = mock_logger
|
31
|
+
DispatchRider.config.debug = true
|
32
|
+
end
|
33
|
+
|
34
|
+
after do
|
35
|
+
DispatchRider.clear_configuration!
|
36
|
+
end
|
37
|
+
|
38
|
+
context "successful handler" do
|
39
|
+
before do
|
40
|
+
publisher.publish message: { subject: 'sample_handler', body: {} }, destinations: :dst
|
41
|
+
work_off_jobs(subscriber)
|
42
|
+
end
|
43
|
+
|
44
|
+
example "full logging integration in json mode" do
|
45
|
+
expected1 = {
|
46
|
+
'phase' => 'start',
|
47
|
+
'guid' => 'test-mode-not-random-guid',
|
48
|
+
'subject' => 'sample_handler',
|
49
|
+
'body' => {},
|
50
|
+
}
|
51
|
+
|
52
|
+
expected2 = {
|
53
|
+
'phase' => 'success',
|
54
|
+
'guid' => 'test-mode-not-random-guid',
|
55
|
+
'subject' => 'sample_handler',
|
56
|
+
'body' => {},
|
57
|
+
}
|
58
|
+
|
59
|
+
expected3 = {
|
60
|
+
'phase' => 'complete',
|
61
|
+
'guid' => 'test-mode-not-random-guid',
|
62
|
+
'subject' => 'sample_handler',
|
63
|
+
'body' => {},
|
64
|
+
}
|
65
|
+
|
66
|
+
expect(mock_logger.log.count).to eq(3)
|
67
|
+
|
68
|
+
expect(mock_logger.log[0]).to eq(level: :info, message: expected1.to_json)
|
69
|
+
expect(mock_logger.log[1]).to eq(level: :info, message: expected2.to_json)
|
70
|
+
|
71
|
+
# last one is a bit harder since it has a relative 'duration' value
|
72
|
+
entry = mock_logger.log[2]
|
73
|
+
expect(entry[:level]).to eq(:info)
|
74
|
+
payload = JSON.load(entry[:message])
|
75
|
+
expect(payload['duration']).to be_a(Numeric)
|
76
|
+
payload.delete 'duration'
|
77
|
+
expect(payload).to eq(expected3)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
context "failing handler" do
|
82
|
+
before do
|
83
|
+
publisher.publish message: { subject: 'crashing_handler', body: {} }, destinations: :dst
|
84
|
+
work_off_jobs(subscriber, fail_on_error: false)
|
85
|
+
end
|
86
|
+
|
87
|
+
example "full logging integration in json mode" do
|
88
|
+
expected1 = {
|
89
|
+
'phase' => 'start',
|
90
|
+
'guid' => 'test-mode-not-random-guid',
|
91
|
+
'subject' => 'crashing_handler',
|
92
|
+
'body' => {},
|
93
|
+
}
|
94
|
+
|
95
|
+
expected2 = {
|
96
|
+
'phase' => 'fail',
|
97
|
+
'guid' => 'test-mode-not-random-guid',
|
98
|
+
'subject' => 'crashing_handler',
|
99
|
+
'body' => {},
|
100
|
+
'expection' => {
|
101
|
+
'class' => 'RuntimeError',
|
102
|
+
'message' => 'I crashed!',
|
103
|
+
},
|
104
|
+
}
|
105
|
+
|
106
|
+
expected3 = {
|
107
|
+
'phase' => 'complete',
|
108
|
+
'guid' => 'test-mode-not-random-guid',
|
109
|
+
'subject' => 'crashing_handler',
|
110
|
+
'body' => {},
|
111
|
+
}
|
112
|
+
|
113
|
+
expect(mock_logger.log.count).to eq(3)
|
114
|
+
|
115
|
+
expect(mock_logger.log[0]).to eq(level: :info, message: expected1.to_json)
|
116
|
+
expect(mock_logger.log[1]).to eq(level: :error, message: expected2.to_json)
|
117
|
+
|
118
|
+
# last one is a bit harder since it has a relative 'duration' value
|
119
|
+
entry = mock_logger.log[2]
|
120
|
+
expect(entry[:level]).to eq(:info)
|
121
|
+
payload = JSON.load(entry[:message])
|
122
|
+
expect(payload['duration']).to be_a(Numeric)
|
123
|
+
payload.delete 'duration'
|
124
|
+
expect(payload).to eq(expected3)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
end
|
@@ -59,7 +59,6 @@ describe DispatchRider::Demultiplexer, nodb: true do
|
|
59
59
|
demultiplexer_thread.run
|
60
60
|
sleep 0.01 # give it a chance to process the job async before killing the demux
|
61
61
|
end
|
62
|
-
|
63
62
|
# THIS ALSO TESTS THAT THE JOB IS NOT RUN MULTIPLE TIMES
|
64
63
|
# IF THIS FAILS, BE CAREFUL NOT TO INTRODUCE BUGS
|
65
64
|
it "should call the correct handler" do
|
@@ -14,12 +14,18 @@ describe DispatchRider::Dispatcher, :nodb => true do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe "#dispatch" do
|
17
|
-
let(:
|
17
|
+
let(:message_subject) { "handle_something" }
|
18
|
+
let(:message_body) { { do_throw_something: true } }
|
19
|
+
let(:fs_message) do
|
20
|
+
DispatchRider::Message.new(subject: message_subject, body: message_body.merge('guid' => 123))
|
21
|
+
end
|
22
|
+
let(:item) { double :item }
|
23
|
+
let(:queue) { double :queue }
|
24
|
+
let(:message) { DispatchRider::QueueServices::FileSystem::FsReceivedMessage.new(fs_message, item, queue) }
|
18
25
|
|
19
26
|
describe "callbacks" do
|
20
27
|
let(:dummy) { double(:dummy) }
|
21
28
|
let(:storage) { DispatchRider::Callbacks::Storage.new }
|
22
|
-
let(:message) { DispatchRider::Message.new(subject: "handle_something", body: { do_throw_something: true }) }
|
23
29
|
|
24
30
|
before do
|
25
31
|
allow(DispatchRider.config).to receive(:callbacks) { storage }
|
@@ -55,9 +61,7 @@ describe DispatchRider::Dispatcher, :nodb => true do
|
|
55
61
|
end
|
56
62
|
|
57
63
|
context "when the handler returns false" do
|
58
|
-
let(:
|
59
|
-
DispatchRider::Message.new(subject: "handler_that_returns_false", body: { do_throw_something: true })
|
60
|
-
end
|
64
|
+
let(:message_subject) { "handler_that_returns_false" }
|
61
65
|
|
62
66
|
before :each do
|
63
67
|
subject.register('handler_that_returns_false')
|
@@ -56,7 +56,7 @@ describe DispatchRider::Logging::JsonFormatter do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
context "complete" do
|
59
|
-
let(:formatted_message) { result_object.merge("phase" => "complete", "duration" =>
|
59
|
+
let(:formatted_message) { result_object.merge("phase" => "complete", "duration" => 2.0) }
|
60
60
|
let(:result_message) { JSON.parse subject.format_handling(:complete, message, duration: 2.0) }
|
61
61
|
|
62
62
|
example { expect(result_message).to eq(formatted_message) }
|
@@ -1,6 +1,14 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe DispatchRider::Subscriber do
|
4
|
+
let(:message_subject) { "handle_something" }
|
5
|
+
let(:message_body) { { do_throw_something: true } }
|
6
|
+
let(:fs_message) do
|
7
|
+
DispatchRider::Message.new(subject: message_subject, body: message_body.merge('guid' => 123))
|
8
|
+
end
|
9
|
+
let(:item) { double :item }
|
10
|
+
let(:queue) { double :queue }
|
11
|
+
let(:message) { DispatchRider::QueueServices::FileSystem::FsReceivedMessage.new(fs_message, item, queue) }
|
4
12
|
|
5
13
|
before do
|
6
14
|
allow(DispatchRider::Handlers::Base).to receive(:subclasses) { Set.new }
|
@@ -27,20 +35,19 @@ describe DispatchRider::Subscriber do
|
|
27
35
|
end
|
28
36
|
|
29
37
|
describe "#register_handler" do
|
38
|
+
let(:message_subject) { :foo_bar }
|
39
|
+
let(:message_body) { { 'foo' => 'bar' } }
|
40
|
+
|
30
41
|
it "should register a handler" do
|
31
42
|
subject.register_handler(:foo_bar)
|
32
43
|
expect {
|
33
|
-
message = DispatchRider::Message.new(subject: :foo_bar, body: { 'foo' => 'bar' })
|
34
44
|
subject.dispatcher.dispatch(message)
|
35
45
|
}.to throw_symbol(:process_was_called)
|
36
46
|
end
|
37
|
-
end
|
38
47
|
|
39
|
-
describe "#register_handlers" do
|
40
48
|
it "should register all the handlers" do
|
41
49
|
subject.register_handlers(:foo_bar)
|
42
50
|
expect {
|
43
|
-
message = DispatchRider::Message.new(subject: :foo_bar, body: { 'foo' => 'bar' })
|
44
51
|
subject.dispatcher.dispatch(message)
|
45
52
|
}.to throw_symbol(:process_was_called)
|
46
53
|
end
|
@@ -82,8 +89,10 @@ describe DispatchRider::Subscriber do
|
|
82
89
|
# kills travis sometimes so leaving it here as tested documentation
|
83
90
|
describe "process termination", if: false do
|
84
91
|
before { allow(subject.demultiplexer).to receive(:stop) { throw :got_stopped } }
|
92
|
+
let(:message_body) { { 'foo' => 'bar' } }
|
85
93
|
|
86
94
|
context "when process quits" do
|
95
|
+
let(:message_subject) { :quiter }
|
87
96
|
before do
|
88
97
|
konst = Class.new(DispatchRider::Handlers::Base) do
|
89
98
|
def process(_options)
|
@@ -93,7 +102,6 @@ describe DispatchRider::Subscriber do
|
|
93
102
|
stub_const("Quiter", konst)
|
94
103
|
|
95
104
|
subject.register_handler(:quiter)
|
96
|
-
message = DispatchRider::Message.new(subject: :quiter, body: {})
|
97
105
|
subject.queue_service_registrar.fetch(:simple).push(message)
|
98
106
|
end
|
99
107
|
|
@@ -101,6 +109,7 @@ describe DispatchRider::Subscriber do
|
|
101
109
|
end
|
102
110
|
|
103
111
|
context "when process terminates" do
|
112
|
+
let(:message_subject) { :terminator }
|
104
113
|
before do
|
105
114
|
konst = Class.new(DispatchRider::Handlers::Base) do
|
106
115
|
def process(_options)
|
@@ -109,7 +118,6 @@ describe DispatchRider::Subscriber do
|
|
109
118
|
end
|
110
119
|
stub_const("Terminator", konst)
|
111
120
|
subject.register_handler(:terminator)
|
112
|
-
message = DispatchRider::Message.new(subject: :terminator, body: {})
|
113
121
|
subject.queue_service_registrar.fetch(:simple).push(message)
|
114
122
|
end
|
115
123
|
|
@@ -117,6 +125,7 @@ describe DispatchRider::Subscriber do
|
|
117
125
|
end
|
118
126
|
|
119
127
|
context "when process is interupted" do
|
128
|
+
let(:message_subject) { :interupter }
|
120
129
|
before do
|
121
130
|
konst = Class.new(DispatchRider::Handlers::Base) do
|
122
131
|
def process(_options)
|
@@ -125,7 +134,6 @@ describe DispatchRider::Subscriber do
|
|
125
134
|
end
|
126
135
|
stub_const("Interupter", konst)
|
127
136
|
subject.register_handler(:interupter)
|
128
|
-
message = DispatchRider::Message.new(subject: :interupter, body: {})
|
129
137
|
subject.queue_service_registrar.fetch(:simple).push(message)
|
130
138
|
end
|
131
139
|
|
@@ -133,6 +141,7 @@ describe DispatchRider::Subscriber do
|
|
133
141
|
end
|
134
142
|
|
135
143
|
context "when process is interupted twice" do
|
144
|
+
let(:message_subject) { :twice_interupter }
|
136
145
|
before do
|
137
146
|
allow(subject.demultiplexer).to receive(:stop) # do nothing just ignore the interuption
|
138
147
|
allow(subject).to receive(:exit) { throw :got_forcefully_stopped }
|
@@ -144,7 +153,6 @@ describe DispatchRider::Subscriber do
|
|
144
153
|
end
|
145
154
|
stub_const("TwiceInterupter", konst)
|
146
155
|
subject.register_handler(:twice_interupter)
|
147
|
-
message = DispatchRider::Message.new(subject: :twice_interupter, body: {})
|
148
156
|
subject.queue_service_registrar.fetch(:simple).push(message)
|
149
157
|
end
|
150
158
|
|
data/spec/spec_helper.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
1
|
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
2
2
|
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
3
3
|
|
4
|
+
Bundler.require
|
5
|
+
|
4
6
|
require 'aws'
|
5
7
|
require 'rake'
|
6
8
|
require 'tempfile'
|
7
9
|
|
10
|
+
require 'dispatch-rider'
|
11
|
+
Dir['./spec/support/**/*.rb'].each { |fn| require(fn) }
|
12
|
+
|
8
13
|
RSpec.configure do |config|
|
9
14
|
config.raise_errors_for_deprecations!
|
10
15
|
config.mock_with :rspec
|
@@ -14,10 +19,14 @@ RSpec.configure do |config|
|
|
14
19
|
config.mock_with :rspec do |mocks|
|
15
20
|
mocks.yield_receiver_to_any_instance_implementation_blocks = false
|
16
21
|
end
|
22
|
+
|
23
|
+
config.include IntegrationSupport
|
24
|
+
|
25
|
+
config.before do
|
26
|
+
DispatchRider.config.logger = NullLogger.new
|
27
|
+
end
|
17
28
|
end
|
18
29
|
|
19
30
|
# Airbrake dummy module
|
20
31
|
module Airbrake
|
21
32
|
end
|
22
|
-
|
23
|
-
require 'dispatch-rider'
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module IntegrationSupport
|
2
|
+
def setup_publisher
|
3
|
+
publisher = DispatchRider::Publisher.new
|
4
|
+
publisher.register_notification_service :file_system
|
5
|
+
publisher.register_destination :dst, :file_system, :dst_channel, path: 'tmp/test_queue'
|
6
|
+
publisher
|
7
|
+
end
|
8
|
+
|
9
|
+
def purge_test_queue
|
10
|
+
Dir['tmp/test_queue/*'].each { |fn| File.unlink(fn) }
|
11
|
+
end
|
12
|
+
|
13
|
+
def setup_subscriber
|
14
|
+
subscriber = DispatchRider.config.subscriber.new
|
15
|
+
subscriber.register_queue(:file_system, path: 'tmp/test_queue')
|
16
|
+
subscriber.register_handler(:sample_handler)
|
17
|
+
subscriber.register_handler(:crashing_handler)
|
18
|
+
subscriber
|
19
|
+
end
|
20
|
+
|
21
|
+
def work_off_jobs(subscriber, fail_on_error: true)
|
22
|
+
subscriber.setup_demultiplexer(:file_system, ->(_message, error) { raise error if fail_on_error })
|
23
|
+
|
24
|
+
class << subscriber.demultiplexer
|
25
|
+
def keep_going?
|
26
|
+
!queue.empty?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
subscriber.demultiplexer.start
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dispatch-rider
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Suman Mukherjee
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-06-
|
14
|
+
date: 2015-06-24 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: activesupport
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/generators/dispatch_rider/job/templates/publisher/publisher_spec.rb.erb
|
166
166
|
- spec/fixtures/handlers/another_test_handler.rb
|
167
167
|
- spec/fixtures/handlers/test_handler.rb
|
168
|
+
- spec/integration/logging_spec.rb
|
168
169
|
- spec/lib/dispatch-rider/airbrake_error_handler_spec.rb
|
169
170
|
- spec/lib/dispatch-rider/callbacks/access_spec.rb
|
170
171
|
- spec/lib/dispatch-rider/callbacks/storage_spec.rb
|
@@ -209,6 +210,10 @@ files:
|
|
209
210
|
- spec/lib/dispatch-rider/subscriber_spec.rb
|
210
211
|
- spec/lib/dispatch-rider_spec.rb
|
211
212
|
- spec/spec_helper.rb
|
213
|
+
- spec/support/crashing_handler.rb
|
214
|
+
- spec/support/integration_support.rb
|
215
|
+
- spec/support/null_logger.rb
|
216
|
+
- spec/support/sample_handler.rb
|
212
217
|
homepage: https://github.com/payrollhero/dispatch-rider
|
213
218
|
licenses:
|
214
219
|
- MIT
|
@@ -237,6 +242,7 @@ summary: Messaging system that is customizable based on which queueing system we
|
|
237
242
|
test_files:
|
238
243
|
- spec/fixtures/handlers/another_test_handler.rb
|
239
244
|
- spec/fixtures/handlers/test_handler.rb
|
245
|
+
- spec/integration/logging_spec.rb
|
240
246
|
- spec/lib/dispatch-rider/airbrake_error_handler_spec.rb
|
241
247
|
- spec/lib/dispatch-rider/callbacks/access_spec.rb
|
242
248
|
- spec/lib/dispatch-rider/callbacks/storage_spec.rb
|
@@ -281,3 +287,7 @@ test_files:
|
|
281
287
|
- spec/lib/dispatch-rider/subscriber_spec.rb
|
282
288
|
- spec/lib/dispatch-rider_spec.rb
|
283
289
|
- spec/spec_helper.rb
|
290
|
+
- spec/support/crashing_handler.rb
|
291
|
+
- spec/support/integration_support.rb
|
292
|
+
- spec/support/null_logger.rb
|
293
|
+
- spec/support/sample_handler.rb
|