dispatch-rider 2.0.0 → 2.2.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 +4 -4
- data/.github/workflows/build.yml +5 -4
- data/.rubocop.yml +21 -0
- data/.rubocop_todo.yml +17 -300
- data/CHANGELOG.md +7 -0
- data/Rakefile +2 -1
- data/dispatch-rider.gemspec +3 -3
- data/lib/dispatch-rider/callbacks/access.rb +2 -0
- data/lib/dispatch-rider/callbacks/storage.rb +7 -5
- data/lib/dispatch-rider/callbacks/support.rb +2 -0
- data/lib/dispatch-rider/callbacks.rb +2 -0
- data/lib/dispatch-rider/command.rb +3 -3
- data/lib/dispatch-rider/configuration.rb +3 -1
- data/lib/dispatch-rider/debug.rb +3 -1
- data/lib/dispatch-rider/demultiplexer.rb +17 -19
- data/lib/dispatch-rider/dispatcher.rb +2 -0
- data/lib/dispatch-rider/error_handlers.rb +3 -1
- data/lib/dispatch-rider/errors.rb +2 -0
- data/lib/dispatch-rider/handlers/base.rb +12 -10
- data/lib/dispatch-rider/handlers/inheritance_tracking.rb +2 -0
- data/lib/dispatch-rider/handlers/named_process.rb +2 -0
- data/lib/dispatch-rider/handlers.rb +2 -0
- data/lib/dispatch-rider/integrations/appsignal.rb +3 -1
- data/lib/dispatch-rider/logging/json_formatter.rb +2 -0
- data/lib/dispatch-rider/logging/lifecycle_logger.rb +3 -1
- data/lib/dispatch-rider/logging/text_formatter.rb +2 -0
- data/lib/dispatch-rider/logging/translator/base_translator.rb +3 -1
- data/lib/dispatch-rider/logging/translator/complete_translator.rb +2 -0
- data/lib/dispatch-rider/logging/translator/error_handler_fail_translator.rb +2 -0
- data/lib/dispatch-rider/logging/translator/fail_translator.rb +2 -0
- data/lib/dispatch-rider/logging/translator/start_translator.rb +2 -0
- data/lib/dispatch-rider/logging/translator/stop_translator.rb +2 -0
- data/lib/dispatch-rider/logging/translator/success_translator.rb +2 -0
- data/lib/dispatch-rider/logging/translator.rb +2 -0
- data/lib/dispatch-rider/logging.rb +2 -0
- data/lib/dispatch-rider/message.rb +3 -0
- data/lib/dispatch-rider/notification_services/aws_sns.rb +5 -3
- data/lib/dispatch-rider/notification_services/base.rb +2 -0
- data/lib/dispatch-rider/notification_services/file_system/channel.rb +2 -0
- data/lib/dispatch-rider/notification_services/file_system/notifier.rb +2 -0
- data/lib/dispatch-rider/notification_services/file_system.rb +3 -1
- data/lib/dispatch-rider/notification_services.rb +2 -0
- data/lib/dispatch-rider/publisher/base.rb +2 -0
- data/lib/dispatch-rider/publisher/configuration/destination.rb +6 -4
- data/lib/dispatch-rider/publisher/configuration/notification_service.rb +4 -2
- data/lib/dispatch-rider/publisher/configuration.rb +2 -0
- data/lib/dispatch-rider/publisher/configuration_reader.rb +3 -1
- data/lib/dispatch-rider/publisher/configuration_support.rb +3 -1
- data/lib/dispatch-rider/publisher.rb +7 -12
- data/lib/dispatch-rider/queue_services/aws_sqs/message_body_extractor.rb +2 -0
- data/lib/dispatch-rider/queue_services/aws_sqs/sqs_received_message.rb +6 -4
- data/lib/dispatch-rider/queue_services/aws_sqs.rb +5 -2
- data/lib/dispatch-rider/queue_services/base.rb +5 -4
- data/lib/dispatch-rider/queue_services/file_system/fs_received_message.rb +5 -3
- data/lib/dispatch-rider/queue_services/file_system/queue.rb +5 -4
- data/lib/dispatch-rider/queue_services/file_system.rb +7 -11
- data/lib/dispatch-rider/queue_services/received_message.rb +3 -1
- data/lib/dispatch-rider/queue_services/simple.rb +5 -7
- data/lib/dispatch-rider/queue_services.rb +2 -0
- data/lib/dispatch-rider/registrars/base.rb +5 -5
- data/lib/dispatch-rider/registrars/file_system_channel.rb +3 -1
- data/lib/dispatch-rider/registrars/handler.rb +3 -1
- data/lib/dispatch-rider/registrars/notification_service.rb +2 -0
- data/lib/dispatch-rider/registrars/publishing_destination.rb +3 -1
- data/lib/dispatch-rider/registrars/queue_service.rb +2 -0
- data/lib/dispatch-rider/registrars/sns_channel.rb +3 -1
- data/lib/dispatch-rider/registrars.rb +2 -0
- data/lib/dispatch-rider/runner.rb +2 -0
- data/lib/dispatch-rider/scheduled_job/migration.rb +2 -0
- data/lib/dispatch-rider/scheduled_job.rb +3 -3
- data/lib/dispatch-rider/subscriber.rb +2 -0
- data/lib/dispatch-rider/version.rb +3 -1
- data/lib/dispatch-rider.rb +3 -1
- data/lib/generators/dispatch_rider/install/install_generator.rb +2 -0
- data/lib/generators/dispatch_rider/install/templates/script/dispatch_rider +1 -0
- data/lib/generators/dispatch_rider/job/dispatch_job_generator.rb +2 -0
- data/spec/factories/messages.rb +4 -1
- data/spec/fixtures/handlers/another_test_handler.rb +2 -0
- data/spec/fixtures/handlers/test_handler.rb +2 -0
- data/spec/integration/logging_spec.rb +2 -0
- data/spec/lib/dispatch-rider/airbrake_error_handler_spec.rb +3 -1
- data/spec/lib/dispatch-rider/callbacks/access_spec.rb +2 -0
- data/spec/lib/dispatch-rider/callbacks/storage_spec.rb +2 -0
- data/spec/lib/dispatch-rider/configuration_spec.rb +3 -1
- data/spec/lib/dispatch-rider/default_error_handler_spec.rb +2 -0
- data/spec/lib/dispatch-rider/demultiplexer_spec.rb +4 -2
- data/spec/lib/dispatch-rider/dispatcher_spec.rb +12 -9
- data/spec/lib/dispatch-rider/handlers/base_spec.rb +2 -0
- data/spec/lib/dispatch-rider/handlers/inheritance_tracking_spec.rb +2 -0
- data/spec/lib/dispatch-rider/logging/json_formatter_spec.rb +2 -0
- data/spec/lib/dispatch-rider/logging/lifecycle_logger_spec.rb +3 -1
- data/spec/lib/dispatch-rider/logging/text_formatter_spec.rb +2 -0
- data/spec/lib/dispatch-rider/logging/translator_spec.rb +2 -0
- data/spec/lib/dispatch-rider/message_spec.rb +7 -5
- data/spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb +2 -0
- data/spec/lib/dispatch-rider/notification_services/base_spec.rb +6 -4
- data/spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb +2 -0
- data/spec/lib/dispatch-rider/notification_services/file_system/notifier_spec.rb +2 -0
- data/spec/lib/dispatch-rider/notification_services/file_system_spec.rb +2 -0
- data/spec/lib/dispatch-rider/notification_services_spec.rb +2 -0
- data/spec/lib/dispatch-rider/publisher/base_spec.rb +2 -0
- data/spec/lib/dispatch-rider/publisher/configuration/destination_spec.rb +2 -0
- data/spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb +2 -0
- data/spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb +15 -4
- data/spec/lib/dispatch-rider/publisher/configuration_spec.rb +3 -1
- data/spec/lib/dispatch-rider/publisher/configuration_support_spec.rb +4 -2
- data/spec/lib/dispatch-rider/publisher_spec.rb +15 -22
- data/spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb +11 -4
- data/spec/lib/dispatch-rider/queue_services/base_spec.rb +10 -8
- data/spec/lib/dispatch-rider/queue_services/file_system_spec.rb +7 -5
- data/spec/lib/dispatch-rider/queue_services/received_message_spec.rb +2 -0
- data/spec/lib/dispatch-rider/queue_services/simple_spec.rb +6 -4
- data/spec/lib/dispatch-rider/registrars/base_spec.rb +4 -2
- data/spec/lib/dispatch-rider/registrars/file_system_channel_spec.rb +2 -0
- data/spec/lib/dispatch-rider/registrars/handler_spec.rb +2 -0
- data/spec/lib/dispatch-rider/registrars/notification_service_spec.rb +2 -0
- data/spec/lib/dispatch-rider/registrars/publishing_destination_spec.rb +2 -0
- data/spec/lib/dispatch-rider/registrars/queue_service_spec.rb +2 -0
- data/spec/lib/dispatch-rider/registrars/sns_channel_spec.rb +2 -0
- data/spec/lib/dispatch-rider/registrars_spec.rb +2 -0
- data/spec/lib/dispatch-rider/runner_spec.rb +3 -1
- data/spec/lib/dispatch-rider/scheduled_job_spec.rb +2 -0
- data/spec/lib/dispatch-rider/subscriber_spec.rb +6 -3
- data/spec/lib/dispatch-rider_spec.rb +2 -0
- data/spec/spec_helper.rb +2 -1
- data/spec/support/crashing_handler.rb +2 -0
- data/spec/support/integration_support.rb +2 -0
- data/spec/support/null_logger.rb +2 -0
- data/spec/support/sample_handler.rb +2 -0
- metadata +30 -30
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::NotificationServices::Base do
|
|
4
6
|
subject do
|
|
5
|
-
|
|
7
|
+
described_class.new(topics: {})
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
let :channel do
|
|
@@ -15,7 +17,7 @@ describe DispatchRider::NotificationServices::Base do
|
|
|
15
17
|
channel
|
|
16
18
|
end
|
|
17
19
|
|
|
18
|
-
before
|
|
20
|
+
before do
|
|
19
21
|
allow_any_instance_of(described_class).to receive(:notifier_builder).and_return(OpenStruct)
|
|
20
22
|
channel = DispatchRider::Registrars::SnsChannel
|
|
21
23
|
allow_any_instance_of(described_class).to receive(:channel_registrar_builder).and_return(channel)
|
|
@@ -35,7 +37,7 @@ describe DispatchRider::NotificationServices::Base do
|
|
|
35
37
|
end
|
|
36
38
|
|
|
37
39
|
describe "#publish" do
|
|
38
|
-
before
|
|
40
|
+
before do
|
|
39
41
|
subject.register(:foo, account: 123, region: "us-east-1", topic: "PlanOfAttack")
|
|
40
42
|
subject.notifier.topics['arn:aws:sns:us-east-1:123:PlanOfAttack'] = channel
|
|
41
43
|
end
|
|
@@ -70,7 +72,7 @@ describe DispatchRider::NotificationServices::Base do
|
|
|
70
72
|
end
|
|
71
73
|
|
|
72
74
|
describe "#channels" do
|
|
73
|
-
before
|
|
75
|
+
before do
|
|
74
76
|
subject.register(:foo, account: 123, region: "us-east-1", topic: "PlanOfAttack")
|
|
75
77
|
subject.notifier.topics['arn:aws:sns:us-east-1:123:PlanOfAttack'] = channel
|
|
76
78
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::Publisher::ConfigurationReader do
|
|
@@ -55,7 +57,11 @@ describe DispatchRider::Publisher::ConfigurationReader do
|
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
it "calls register_notification_service with :file_system and {}" do
|
|
58
|
-
|
|
60
|
+
if RUBY_VERSION > '3'
|
|
61
|
+
expect(publisher).to receive(:register_notification_service).with("file_system").once
|
|
62
|
+
else
|
|
63
|
+
expect(publisher).to receive(:register_notification_service).with("file_system", {}).once
|
|
64
|
+
end
|
|
59
65
|
subject.load_config(configuration, publisher)
|
|
60
66
|
end
|
|
61
67
|
end
|
|
@@ -71,8 +77,13 @@ describe DispatchRider::Publisher::ConfigurationReader do
|
|
|
71
77
|
end
|
|
72
78
|
|
|
73
79
|
it "calls register_notification_service with :file_system and {}, as well as :foo, {bar: '123'}" do
|
|
74
|
-
|
|
75
|
-
|
|
80
|
+
if RUBY_VERSION > '3'
|
|
81
|
+
expect(publisher).to receive(:register_notification_service).with("file_system").once
|
|
82
|
+
expect(publisher).to receive(:register_notification_service).with("foo", bar: "123").once
|
|
83
|
+
else
|
|
84
|
+
expect(publisher).to receive(:register_notification_service).with("file_system", {}).once
|
|
85
|
+
expect(publisher).to receive(:register_notification_service).with("foo", "bar" => "123").once
|
|
86
|
+
end
|
|
76
87
|
subject.load_config(configuration, publisher)
|
|
77
88
|
end
|
|
78
89
|
end
|
|
@@ -117,7 +128,7 @@ describe DispatchRider::Publisher::ConfigurationReader do
|
|
|
117
128
|
|
|
118
129
|
it "should call register_destination with the right parameters" do
|
|
119
130
|
params = ["out1", :file_system, :foo, "path" => "tmp/test/channel"]
|
|
120
|
-
expect(publisher).to receive(:register_destination).
|
|
131
|
+
expect(publisher).to receive(:register_destination).once.with(*params)
|
|
121
132
|
subject.load_config(configuration, publisher)
|
|
122
133
|
end
|
|
123
134
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::Publisher::Configuration do
|
|
@@ -131,7 +133,7 @@ describe DispatchRider::Publisher::Configuration do
|
|
|
131
133
|
)
|
|
132
134
|
end
|
|
133
135
|
|
|
134
|
-
before
|
|
136
|
+
before do
|
|
135
137
|
subject.parse(new_configuration_hash)
|
|
136
138
|
end
|
|
137
139
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::Publisher::ConfigurationSupport do
|
|
@@ -52,7 +54,7 @@ describe DispatchRider::Publisher::ConfigurationSupport do
|
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
context "when configuring with a hash" do
|
|
55
|
-
before
|
|
57
|
+
before do
|
|
56
58
|
subject.configure(configuration_hash)
|
|
57
59
|
end
|
|
58
60
|
|
|
@@ -68,7 +70,7 @@ describe DispatchRider::Publisher::ConfigurationSupport do
|
|
|
68
70
|
end
|
|
69
71
|
|
|
70
72
|
context "when configuring with a block" do
|
|
71
|
-
before
|
|
73
|
+
before do
|
|
72
74
|
subject.configure do |config|
|
|
73
75
|
config.parse(configuration_hash)
|
|
74
76
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::Publisher do
|
|
@@ -55,7 +57,7 @@ describe DispatchRider::Publisher do
|
|
|
55
57
|
end
|
|
56
58
|
|
|
57
59
|
describe "#register_channel" do
|
|
58
|
-
before
|
|
60
|
+
before do
|
|
59
61
|
subject.register_notification_service(:aws_sns)
|
|
60
62
|
end
|
|
61
63
|
|
|
@@ -72,7 +74,7 @@ describe DispatchRider::Publisher do
|
|
|
72
74
|
end
|
|
73
75
|
|
|
74
76
|
describe "#register_destination" do
|
|
75
|
-
before
|
|
77
|
+
before do
|
|
76
78
|
subject.register_notification_service(:aws_sns)
|
|
77
79
|
end
|
|
78
80
|
|
|
@@ -100,18 +102,18 @@ describe DispatchRider::Publisher do
|
|
|
100
102
|
subject.notification_service_registrar.fetch(:aws_sns).notifier
|
|
101
103
|
end
|
|
102
104
|
|
|
103
|
-
before
|
|
105
|
+
before do
|
|
104
106
|
subject.register_notification_service(:file_system)
|
|
105
107
|
subject.register_destination(:fs_foo, :file_system, :foo, path: "tmp/test_queue")
|
|
106
108
|
end
|
|
107
109
|
|
|
108
110
|
around do |ex|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
111
|
+
|
|
112
|
+
DispatchRider.config.debug = true
|
|
113
|
+
ex.call
|
|
114
|
+
ensure
|
|
115
|
+
DispatchRider.config.debug = false
|
|
116
|
+
|
|
115
117
|
end
|
|
116
118
|
|
|
117
119
|
it "publishes the message to the notification service" do
|
|
@@ -135,25 +137,16 @@ describe DispatchRider::Publisher do
|
|
|
135
137
|
describe "calls publish callback" do
|
|
136
138
|
describe "calls the publish callback" do
|
|
137
139
|
let(:publish_callback) { double :callback }
|
|
138
|
-
let(:expected_message) {
|
|
139
|
-
DispatchRider::Message.new(
|
|
140
|
-
subject: "bar_handler",
|
|
141
|
-
body: {
|
|
142
|
-
"bar" => "baz",
|
|
143
|
-
guid: "test-mode-not-random-guid"
|
|
144
|
-
}
|
|
145
|
-
)
|
|
146
|
-
}
|
|
147
140
|
|
|
148
141
|
before { DispatchRider.config.callbacks.for(:publish) << publish_callback }
|
|
149
142
|
|
|
150
143
|
after { DispatchRider.config.callbacks.for(:publish).delete publish_callback }
|
|
151
144
|
|
|
152
145
|
example do
|
|
153
|
-
expect(publish_callback).to receive(:call).with
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
146
|
+
expect(publish_callback).to receive(:call).with(
|
|
147
|
+
an_instance_of(Proc), # first argument is the inner job
|
|
148
|
+
{ destinations: [:fs_foo],
|
|
149
|
+
message: an_instance_of(DispatchRider::Message) })
|
|
157
150
|
publisher.publish destinations: [:fs_foo],
|
|
158
151
|
message: {
|
|
159
152
|
subject: "bar_handler",
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::QueueServices::AwsSqs do
|
|
4
6
|
|
|
5
7
|
subject(:aws_sqs_queue) do
|
|
6
|
-
|
|
8
|
+
described_class.new(:name => "normal_priority")
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
let(:visibility_timeout) { 100 }
|
|
10
12
|
|
|
11
13
|
before do
|
|
12
|
-
allow_any_instance_of(Aws::SQS::Client).to receive(:list_queues).and_return(OpenStruct.new({queue_urls:["the.queue.url"]}))
|
|
14
|
+
allow_any_instance_of(Aws::SQS::Client).to receive(:list_queues).and_return(OpenStruct.new({queue_urls: ["the.queue.url"]}))
|
|
13
15
|
allow_any_instance_of(Aws::SQS::Client).to receive(:get_queue_attributes).and_return(
|
|
14
|
-
OpenStruct.new(
|
|
16
|
+
OpenStruct.new(
|
|
17
|
+
{
|
|
18
|
+
attributes: {"VisibilityTimeout"=>visibility_timeout}
|
|
19
|
+
}
|
|
20
|
+
)
|
|
15
21
|
)
|
|
16
22
|
end
|
|
17
23
|
|
|
@@ -99,7 +105,7 @@ describe DispatchRider::QueueServices::AwsSqs do
|
|
|
99
105
|
end
|
|
100
106
|
|
|
101
107
|
context "when the sqs queue is empty" do
|
|
102
|
-
before
|
|
108
|
+
before do
|
|
103
109
|
allow_any_instance_of(Aws::SQS::Queue).to receive(:receive_messages).and_return(OpenStruct.new({first: nil }))
|
|
104
110
|
end
|
|
105
111
|
|
|
@@ -134,6 +140,7 @@ describe DispatchRider::QueueServices::AwsSqs do
|
|
|
134
140
|
end
|
|
135
141
|
|
|
136
142
|
before do
|
|
143
|
+
allow(response_message).to receive(:change_visibility)
|
|
137
144
|
allow_any_instance_of(Aws::SQS::Queue).to receive(:receive_messages).and_return(OpenStruct.new({first: response_message }))
|
|
138
145
|
end
|
|
139
146
|
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::QueueServices::Base do
|
|
4
6
|
subject(:base_queue) do
|
|
5
|
-
allow_any_instance_of(
|
|
6
|
-
|
|
7
|
+
allow_any_instance_of(described_class).to receive(:assign_storage).and_return([])
|
|
8
|
+
described_class.new
|
|
7
9
|
end
|
|
8
10
|
|
|
9
11
|
describe "#initialize" do
|
|
@@ -34,7 +36,7 @@ describe DispatchRider::QueueServices::Base do
|
|
|
34
36
|
describe "#pop" do
|
|
35
37
|
subject(:simple_queue) { DispatchRider::QueueServices::Simple.new }
|
|
36
38
|
|
|
37
|
-
before
|
|
39
|
+
before do
|
|
38
40
|
simple_queue.queue.push(DispatchRider::Message.new(subject: "foo", body: "bar").to_json)
|
|
39
41
|
end
|
|
40
42
|
|
|
@@ -61,7 +63,7 @@ describe DispatchRider::QueueServices::Base do
|
|
|
61
63
|
end
|
|
62
64
|
|
|
63
65
|
context "when the queue is empty" do
|
|
64
|
-
before
|
|
66
|
+
before do
|
|
65
67
|
simple_queue.queue = []
|
|
66
68
|
end
|
|
67
69
|
|
|
@@ -90,7 +92,7 @@ describe DispatchRider::QueueServices::Base do
|
|
|
90
92
|
|
|
91
93
|
context "when a new item exists" do
|
|
92
94
|
before do
|
|
93
|
-
allow(base_queue).to receive(:construct_message_from
|
|
95
|
+
allow(base_queue).to receive(:construct_message_from, &:message)
|
|
94
96
|
end
|
|
95
97
|
|
|
96
98
|
let(:new_item) { OpenStruct.new(message: new_message) }
|
|
@@ -127,12 +129,12 @@ describe DispatchRider::QueueServices::Base do
|
|
|
127
129
|
end
|
|
128
130
|
|
|
129
131
|
describe "#empty?" do
|
|
130
|
-
before
|
|
132
|
+
before do
|
|
131
133
|
allow(base_queue).to receive(:size) { base_queue.queue.size }
|
|
132
134
|
end
|
|
133
135
|
|
|
134
136
|
context "when the queue is empty" do
|
|
135
|
-
before
|
|
137
|
+
before do
|
|
136
138
|
base_queue.queue = []
|
|
137
139
|
end
|
|
138
140
|
|
|
@@ -142,7 +144,7 @@ describe DispatchRider::QueueServices::Base do
|
|
|
142
144
|
end
|
|
143
145
|
|
|
144
146
|
context "when the queue is not empty" do
|
|
145
|
-
before
|
|
147
|
+
before do
|
|
146
148
|
base_queue.queue << { subject: 'foo', body: 'bar' }.to_json
|
|
147
149
|
end
|
|
148
150
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::QueueServices::FileSystem do
|
|
4
6
|
subject(:file_system_queue) do
|
|
5
|
-
|
|
7
|
+
described_class.new(:path => queue_path)
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
let(:queue_path) { "tmp/queue" }
|
|
@@ -26,7 +28,7 @@ describe DispatchRider::QueueServices::FileSystem do
|
|
|
26
28
|
end
|
|
27
29
|
|
|
28
30
|
describe "#raw_head" do
|
|
29
|
-
before
|
|
31
|
+
before do
|
|
30
32
|
file_system_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
|
|
31
33
|
end
|
|
32
34
|
|
|
@@ -53,7 +55,7 @@ describe DispatchRider::QueueServices::FileSystem do
|
|
|
53
55
|
end
|
|
54
56
|
|
|
55
57
|
describe "#put_back" do
|
|
56
|
-
before
|
|
58
|
+
before do
|
|
57
59
|
file_system_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
|
|
58
60
|
end
|
|
59
61
|
|
|
@@ -66,7 +68,7 @@ describe DispatchRider::QueueServices::FileSystem do
|
|
|
66
68
|
end
|
|
67
69
|
|
|
68
70
|
describe "#delete" do
|
|
69
|
-
before
|
|
71
|
+
before do
|
|
70
72
|
file_system_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
|
|
71
73
|
end
|
|
72
74
|
|
|
@@ -78,7 +80,7 @@ describe DispatchRider::QueueServices::FileSystem do
|
|
|
78
80
|
end
|
|
79
81
|
|
|
80
82
|
describe "#size" do
|
|
81
|
-
before
|
|
83
|
+
before do
|
|
82
84
|
file_system_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
|
|
83
85
|
end
|
|
84
86
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::QueueServices::Simple do
|
|
4
6
|
subject(:simple_queue) do
|
|
5
|
-
|
|
7
|
+
described_class.new
|
|
6
8
|
end
|
|
7
9
|
|
|
8
10
|
describe "#assign_storage" do
|
|
@@ -21,7 +23,7 @@ describe DispatchRider::QueueServices::Simple do
|
|
|
21
23
|
end
|
|
22
24
|
|
|
23
25
|
describe "#raw_head" do
|
|
24
|
-
before
|
|
26
|
+
before do
|
|
25
27
|
simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
|
|
26
28
|
end
|
|
27
29
|
|
|
@@ -41,7 +43,7 @@ describe DispatchRider::QueueServices::Simple do
|
|
|
41
43
|
end
|
|
42
44
|
|
|
43
45
|
describe "#delete" do
|
|
44
|
-
before
|
|
46
|
+
before do
|
|
45
47
|
simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
|
|
46
48
|
end
|
|
47
49
|
|
|
@@ -52,7 +54,7 @@ describe DispatchRider::QueueServices::Simple do
|
|
|
52
54
|
end
|
|
53
55
|
|
|
54
56
|
describe "#size" do
|
|
55
|
-
before
|
|
57
|
+
before do
|
|
56
58
|
simple_queue.insert({'subject' => 'foo', 'body' => 'bar'}.to_json)
|
|
57
59
|
end
|
|
58
60
|
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::Registrars::Base do
|
|
@@ -32,7 +34,7 @@ describe DispatchRider::Registrars::Base do
|
|
|
32
34
|
end
|
|
33
35
|
|
|
34
36
|
describe "#unregister" do
|
|
35
|
-
before
|
|
37
|
+
before do
|
|
36
38
|
allow(subject).to receive(:value).and_return('bar')
|
|
37
39
|
subject.register(:foo)
|
|
38
40
|
end
|
|
@@ -49,7 +51,7 @@ describe DispatchRider::Registrars::Base do
|
|
|
49
51
|
|
|
50
52
|
describe "#fetch" do
|
|
51
53
|
context "when a key/value pair is registered" do
|
|
52
|
-
before
|
|
54
|
+
before do
|
|
53
55
|
allow(subject).to receive(:value).and_return('bar')
|
|
54
56
|
subject.register(:foo)
|
|
55
57
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require 'spec_helper'
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::Runner do
|
|
@@ -5,7 +7,7 @@ describe DispatchRider::Runner do
|
|
|
5
7
|
describe ".run" do
|
|
6
8
|
let(:subscriber) { double(:subscriber) }
|
|
7
9
|
|
|
8
|
-
before
|
|
10
|
+
before do
|
|
9
11
|
DispatchRider.configure do |config|
|
|
10
12
|
config.subscriber = subscriber
|
|
11
13
|
end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
require "spec_helper"
|
|
2
4
|
|
|
3
5
|
describe DispatchRider::Subscriber do
|
|
@@ -55,7 +57,7 @@ describe DispatchRider::Subscriber do
|
|
|
55
57
|
|
|
56
58
|
describe "#setup_demultiplexer" do
|
|
57
59
|
context "when a queue is registered" do
|
|
58
|
-
before
|
|
60
|
+
before do
|
|
59
61
|
subject.register_queue(:simple)
|
|
60
62
|
subject.register_handler(:foo_bar)
|
|
61
63
|
end
|
|
@@ -69,7 +71,7 @@ describe DispatchRider::Subscriber do
|
|
|
69
71
|
end
|
|
70
72
|
|
|
71
73
|
describe "#process" do
|
|
72
|
-
before
|
|
74
|
+
before do
|
|
73
75
|
subject.register_queue(:simple)
|
|
74
76
|
subject.register_handler(:foo_bar)
|
|
75
77
|
subject.setup_demultiplexer(:simple)
|
|
@@ -89,6 +91,7 @@ describe DispatchRider::Subscriber do
|
|
|
89
91
|
# kills travis sometimes so leaving it here as tested documentation
|
|
90
92
|
describe "process termination", if: false do
|
|
91
93
|
before { allow(subject.demultiplexer).to receive(:stop) { throw :got_stopped } }
|
|
94
|
+
|
|
92
95
|
let(:message_body) { { 'foo' => 'bar' } }
|
|
93
96
|
|
|
94
97
|
context "when process quits" do
|
|
@@ -151,7 +154,7 @@ describe DispatchRider::Subscriber do
|
|
|
151
154
|
allow(subject).to receive(:exit) { throw :got_forcefully_stopped }
|
|
152
155
|
|
|
153
156
|
konst = Class.new(DispatchRider::Handlers::Base) do
|
|
154
|
-
def process(
|
|
157
|
+
def process(_options)
|
|
155
158
|
2.times { Process.kill("INT", 0) }
|
|
156
159
|
end
|
|
157
160
|
end
|
data/spec/spec_helper.rb
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
require 'bundler/setup'
|
|
4
4
|
|
|
5
5
|
require 'simplecov'
|
|
6
|
+
SimpleCov.minimum_coverage 85
|
|
6
7
|
require 'coveralls'
|
|
7
8
|
|
|
8
9
|
if RUBY_VERSION < "3.1"
|
|
@@ -33,7 +34,7 @@ Bundler.require(:default, :development)
|
|
|
33
34
|
|
|
34
35
|
require 'dispatch-rider'
|
|
35
36
|
|
|
36
|
-
Dir['./spec/support/**/*.rb'].each { |fn| require(fn) }
|
|
37
|
+
Dir['./spec/support/**/*.rb'].sort.each { |fn| require(fn) }
|
|
37
38
|
|
|
38
39
|
FactoryBot.definition_file_paths = %w{spec/factories/}
|
|
39
40
|
FactoryBot.find_definitions
|
data/spec/support/null_logger.rb
CHANGED