dispatch-rider 1.5.3 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +2 -2
  3. data/lib/dispatch-rider.rb +1 -0
  4. data/lib/dispatch-rider/configuration.rb +12 -5
  5. data/lib/dispatch-rider/demultiplexer.rb +3 -27
  6. data/lib/dispatch-rider/logging.rb +10 -0
  7. data/lib/dispatch-rider/logging/base_formatter.rb +30 -0
  8. data/lib/dispatch-rider/logging/json_formatter.rb +75 -0
  9. data/lib/dispatch-rider/logging/lifecycle_logger.rb +53 -0
  10. data/lib/dispatch-rider/logging/text_formatter.rb +48 -0
  11. data/lib/dispatch-rider/queue_services/file_system/queue.rb +13 -2
  12. data/lib/dispatch-rider/version.rb +1 -1
  13. data/spec/lib/dispatch-rider/airbrake_error_handler_spec.rb +10 -3
  14. data/spec/lib/dispatch-rider/callbacks/access_spec.rb +16 -18
  15. data/spec/lib/dispatch-rider/callbacks/storage_spec.rb +4 -9
  16. data/spec/lib/dispatch-rider/configuration_spec.rb +3 -3
  17. data/spec/lib/dispatch-rider/default_error_handler_spec.rb +2 -2
  18. data/spec/lib/dispatch-rider/demultiplexer_spec.rb +14 -14
  19. data/spec/lib/dispatch-rider/dispatcher_spec.rb +10 -8
  20. data/spec/lib/dispatch-rider/handlers/base_spec.rb +27 -22
  21. data/spec/lib/dispatch-rider/handlers/inheritance_tracking_spec.rb +6 -6
  22. data/spec/lib/dispatch-rider/logging/json_formatter_spec.rb +72 -0
  23. data/spec/lib/dispatch-rider/logging/lifecycle_logger_spec.rb +73 -0
  24. data/spec/lib/dispatch-rider/logging/text_formatter_spec.rb +61 -0
  25. data/spec/lib/dispatch-rider/message_spec.rb +11 -11
  26. data/spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb +14 -13
  27. data/spec/lib/dispatch-rider/notification_services/base_spec.rb +18 -13
  28. data/spec/lib/dispatch-rider/notification_services/file_system/channel_spec.rb +2 -3
  29. data/spec/lib/dispatch-rider/notification_services/file_system/notifier_spec.rb +1 -3
  30. data/spec/lib/dispatch-rider/notification_services/file_system_spec.rb +3 -4
  31. data/spec/lib/dispatch-rider/publisher/configuration/destination_spec.rb +30 -21
  32. data/spec/lib/dispatch-rider/publisher/configuration/notification_service_spec.rb +22 -16
  33. data/spec/lib/dispatch-rider/publisher/configuration_reader_spec.rb +11 -10
  34. data/spec/lib/dispatch-rider/publisher/configuration_spec.rb +12 -12
  35. data/spec/lib/dispatch-rider/publisher/configuration_support_spec.rb +11 -11
  36. data/spec/lib/dispatch-rider/publisher_spec.rb +22 -15
  37. data/spec/lib/dispatch-rider/queue_services/aws_sqs_spec.rb +44 -36
  38. data/spec/lib/dispatch-rider/queue_services/base_spec.rb +41 -28
  39. data/spec/lib/dispatch-rider/queue_services/file_system_spec.rb +15 -14
  40. data/spec/lib/dispatch-rider/queue_services/received_message_spec.rb +3 -3
  41. data/spec/lib/dispatch-rider/queue_services/simple_spec.rb +9 -9
  42. data/spec/lib/dispatch-rider/registrars/base_spec.rb +5 -5
  43. data/spec/lib/dispatch-rider/registrars/file_system_channel_spec.rb +3 -3
  44. data/spec/lib/dispatch-rider/registrars/handler_spec.rb +1 -1
  45. data/spec/lib/dispatch-rider/registrars/notification_service_spec.rb +1 -1
  46. data/spec/lib/dispatch-rider/registrars/publishing_destination_spec.rb +2 -2
  47. data/spec/lib/dispatch-rider/registrars/queue_service_spec.rb +1 -1
  48. data/spec/lib/dispatch-rider/registrars/sns_channel_spec.rb +5 -5
  49. data/spec/lib/dispatch-rider/runner_spec.rb +1 -1
  50. data/spec/lib/dispatch-rider/subscriber_spec.rb +45 -29
  51. data/spec/lib/dispatch-rider_spec.rb +3 -3
  52. data/spec/spec_helper.rb +3 -1
  53. metadata +13 -2
@@ -3,7 +3,7 @@ require 'spec_helper'
3
3
  describe DispatchRider::Runner do
4
4
 
5
5
  describe ".run" do
6
- let(:subscriber){ double(:subscriber) }
6
+ let(:subscriber) { double(:subscriber) }
7
7
 
8
8
  before :each do
9
9
  DispatchRider.configure do |config|
@@ -3,39 +3,46 @@ require "spec_helper"
3
3
  describe DispatchRider::Subscriber do
4
4
 
5
5
  before do
6
- DispatchRider::Handlers::Base.stub(:subclasses){ Set.new }
6
+ allow(DispatchRider::Handlers::Base).to receive(:subclasses) { Set.new }
7
7
 
8
- stub_const("FooBar", Class.new(DispatchRider::Handlers::Base) {
9
- def process(options)
8
+ konst = Class.new(DispatchRider::Handlers::Base) do
9
+ def process(_options)
10
10
  throw :process_was_called
11
11
  end
12
- })
12
+ end
13
+ stub_const("FooBar", konst)
13
14
  end
14
15
 
15
16
  describe "#initialize" do
16
17
  it "should assign a new queue service registrar" do
17
- subject.queue_service_registrar.store.should be_empty
18
+ expect(subject.queue_service_registrar.store).to be_empty
18
19
  end
19
20
  end
20
21
 
21
22
  describe "#register_queue" do
22
23
  it "should register a queue service with the queue service registrar" do
23
24
  subject.register_queue(:simple)
24
- subject.queue_service_registrar.fetch(:simple).should be_empty
25
+ expect(subject.queue_service_registrar.fetch(:simple)).to be_empty
25
26
  end
26
27
  end
27
28
 
28
29
  describe "#register_handler" do
29
30
  it "should register a handler" do
30
31
  subject.register_handler(:foo_bar)
31
- expect { subject.dispatcher.dispatch(DispatchRider::Message.new(:subject => :foo_bar, :body => {'foo' => 'bar'})) }.to throw_symbol(:process_was_called)
32
+ expect {
33
+ message = DispatchRider::Message.new(subject: :foo_bar, body: { 'foo' => 'bar' })
34
+ subject.dispatcher.dispatch(message)
35
+ }.to throw_symbol(:process_was_called)
32
36
  end
33
37
  end
34
38
 
35
39
  describe "#register_handlers" do
36
40
  it "should register all the handlers" do
37
41
  subject.register_handlers(:foo_bar)
38
- expect { subject.dispatcher.dispatch(DispatchRider::Message.new(:subject => :foo_bar, :body => {'foo' => 'bar'})) }.to throw_symbol(:process_was_called)
42
+ expect {
43
+ message = DispatchRider::Message.new(subject: :foo_bar, body: { 'foo' => 'bar' })
44
+ subject.dispatcher.dispatch(message)
45
+ }.to throw_symbol(:process_was_called)
39
46
  end
40
47
  end
41
48
 
@@ -48,8 +55,8 @@ describe DispatchRider::Subscriber do
48
55
 
49
56
  it "should assign a demultiplexer" do
50
57
  subject.setup_demultiplexer(:simple)
51
- subject.demultiplexer.queue.should be_empty
52
- subject.demultiplexer.dispatcher.fetch(:foo_bar).should eq(FooBar)
58
+ expect(subject.demultiplexer.queue).to be_empty
59
+ expect(subject.demultiplexer.dispatcher.fetch(:foo_bar)).to eq(FooBar)
53
60
  end
54
61
  end
55
62
  end
@@ -63,7 +70,8 @@ describe DispatchRider::Subscriber do
63
70
 
64
71
  describe "processing" do
65
72
  before do
66
- subject.queue_service_registrar.fetch(:simple).push(DispatchRider::Message.new(subject: :foo_bar, body: {'baz' => 'blah'}))
73
+ message = DispatchRider::Message.new(subject: :foo_bar, body: { 'baz' => 'blah' })
74
+ subject.queue_service_registrar.fetch(:simple).push(message)
67
75
  end
68
76
 
69
77
  it "should process the queue" do
@@ -73,18 +81,20 @@ describe DispatchRider::Subscriber do
73
81
 
74
82
  # kills travis sometimes so leaving it here as tested documentation
75
83
  describe "process termination", if: false do
76
- before { subject.demultiplexer.stub(:stop){ throw :got_stopped } }
84
+ before { allow(subject.demultiplexer).to receive(:stop) { throw :got_stopped } }
77
85
 
78
86
  context "when process quits" do
79
87
  before do
80
- stub_const("Quiter", Class.new(DispatchRider::Handlers::Base) {
81
- def process(options)
88
+ konst = Class.new(DispatchRider::Handlers::Base) do
89
+ def process(_options)
82
90
  Process.kill("QUIT", 0)
83
91
  end
84
- })
92
+ end
93
+ stub_const("Quiter", konst)
85
94
 
86
95
  subject.register_handler(:quiter)
87
- subject.queue_service_registrar.fetch(:simple).push(DispatchRider::Message.new(subject: :quiter, body: {}))
96
+ message = DispatchRider::Message.new(subject: :quiter, body: {})
97
+ subject.queue_service_registrar.fetch(:simple).push(message)
88
98
  end
89
99
 
90
100
  example { expect { subject.process }.to throw_symbol(:got_stopped) }
@@ -92,13 +102,15 @@ describe DispatchRider::Subscriber do
92
102
 
93
103
  context "when process terminates" do
94
104
  before do
95
- stub_const("Terminator", Class.new(DispatchRider::Handlers::Base) {
96
- def process(options)
105
+ konst = Class.new(DispatchRider::Handlers::Base) do
106
+ def process(_options)
97
107
  Process.kill("TERM", 0)
98
108
  end
99
- })
109
+ end
110
+ stub_const("Terminator", konst)
100
111
  subject.register_handler(:terminator)
101
- subject.queue_service_registrar.fetch(:simple).push(DispatchRider::Message.new(subject: :terminator, body: {}))
112
+ message = DispatchRider::Message.new(subject: :terminator, body: {})
113
+ subject.queue_service_registrar.fetch(:simple).push(message)
102
114
  end
103
115
 
104
116
  example { expect { subject.process }.to throw_symbol(:got_stopped) }
@@ -106,13 +118,15 @@ describe DispatchRider::Subscriber do
106
118
 
107
119
  context "when process is interupted" do
108
120
  before do
109
- stub_const("Interupter", Class.new(DispatchRider::Handlers::Base) {
110
- def process(options)
121
+ konst = Class.new(DispatchRider::Handlers::Base) do
122
+ def process(_options)
111
123
  Process.kill("INT", 0)
112
124
  end
113
- })
125
+ end
126
+ stub_const("Interupter", konst)
114
127
  subject.register_handler(:interupter)
115
- subject.queue_service_registrar.fetch(:simple).push(DispatchRider::Message.new(subject: :interupter, body: {}))
128
+ message = DispatchRider::Message.new(subject: :interupter, body: {})
129
+ subject.queue_service_registrar.fetch(:simple).push(message)
116
130
  end
117
131
 
118
132
  example { expect { subject.process }.to throw_symbol(:got_stopped) }
@@ -120,16 +134,18 @@ describe DispatchRider::Subscriber do
120
134
 
121
135
  context "when process is interupted twice" do
122
136
  before do
123
- subject.demultiplexer.stub(:stop) # do nothing just ignore the interuption
124
- subject.stub(:exit){ throw :got_forcefully_stopped }
137
+ allow(subject.demultiplexer).to receive(:stop) # do nothing just ignore the interuption
138
+ allow(subject).to receive(:exit) { throw :got_forcefully_stopped }
125
139
 
126
- stub_const("TwiceInterupter", Class.new(DispatchRider::Handlers::Base) {
140
+ konst = Class.new(DispatchRider::Handlers::Base) do
127
141
  def process(options)
128
142
  2.times { Process.kill("INT", 0) }
129
143
  end
130
- })
144
+ end
145
+ stub_const("TwiceInterupter", konst)
131
146
  subject.register_handler(:twice_interupter)
132
- subject.queue_service_registrar.fetch(:simple).push(DispatchRider::Message.new(subject: :twice_interupter, body: {}))
147
+ message = DispatchRider::Message.new(subject: :twice_interupter, body: {})
148
+ subject.queue_service_registrar.fetch(:simple).push(message)
133
149
  end
134
150
 
135
151
  example { expect { subject.process }.to throw_symbol(:got_forcefully_stopped) }
@@ -4,13 +4,13 @@ describe DispatchRider do
4
4
 
5
5
  describe ".configuration" do
6
6
  example do
7
- described_class.configuration.should be_a(DispatchRider::Configuration)
7
+ expect(described_class.configuration).to be_a(DispatchRider::Configuration)
8
8
  end
9
9
  end
10
10
 
11
11
  describe ".config" do
12
12
  example do
13
- described_class.config.should be_a(DispatchRider::Configuration)
13
+ expect(described_class.config).to be_a(DispatchRider::Configuration)
14
14
  end
15
15
  end
16
16
 
@@ -20,7 +20,7 @@ describe DispatchRider do
20
20
  config.queue_kind = :test_queue
21
21
  end
22
22
 
23
- described_class.config.queue_kind.should == :test_queue
23
+ expect(described_class.config.queue_kind).to eq(:test_queue)
24
24
  end
25
25
  end
26
26
 
@@ -6,6 +6,7 @@ require 'rake'
6
6
  require 'tempfile'
7
7
 
8
8
  RSpec.configure do |config|
9
+ config.raise_errors_for_deprecations!
9
10
  config.mock_with :rspec
10
11
  config.order = 'random'
11
12
  config.color = true
@@ -16,6 +17,7 @@ RSpec.configure do |config|
16
17
  end
17
18
 
18
19
  # Airbrake dummy module
19
- module Airbrake; end
20
+ module Airbrake
21
+ end
20
22
 
21
23
  require 'dispatch-rider'
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.5.3
4
+ version: 1.6.0
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-05-21 00:00:00.000000000 Z
14
+ date: 2015-06-20 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: activesupport
@@ -114,6 +114,11 @@ files:
114
114
  - lib/dispatch-rider/handlers/inheritance_tracking.rb
115
115
  - lib/dispatch-rider/handlers/named_process.rb
116
116
  - lib/dispatch-rider/integrations/appsignal.rb
117
+ - lib/dispatch-rider/logging.rb
118
+ - lib/dispatch-rider/logging/base_formatter.rb
119
+ - lib/dispatch-rider/logging/json_formatter.rb
120
+ - lib/dispatch-rider/logging/lifecycle_logger.rb
121
+ - lib/dispatch-rider/logging/text_formatter.rb
117
122
  - lib/dispatch-rider/message.rb
118
123
  - lib/dispatch-rider/notification_services.rb
119
124
  - lib/dispatch-rider/notification_services/aws_sns.rb
@@ -169,6 +174,9 @@ files:
169
174
  - spec/lib/dispatch-rider/dispatcher_spec.rb
170
175
  - spec/lib/dispatch-rider/handlers/base_spec.rb
171
176
  - spec/lib/dispatch-rider/handlers/inheritance_tracking_spec.rb
177
+ - spec/lib/dispatch-rider/logging/json_formatter_spec.rb
178
+ - spec/lib/dispatch-rider/logging/lifecycle_logger_spec.rb
179
+ - spec/lib/dispatch-rider/logging/text_formatter_spec.rb
172
180
  - spec/lib/dispatch-rider/message_spec.rb
173
181
  - spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
174
182
  - spec/lib/dispatch-rider/notification_services/base_spec.rb
@@ -238,6 +246,9 @@ test_files:
238
246
  - spec/lib/dispatch-rider/dispatcher_spec.rb
239
247
  - spec/lib/dispatch-rider/handlers/base_spec.rb
240
248
  - spec/lib/dispatch-rider/handlers/inheritance_tracking_spec.rb
249
+ - spec/lib/dispatch-rider/logging/json_formatter_spec.rb
250
+ - spec/lib/dispatch-rider/logging/lifecycle_logger_spec.rb
251
+ - spec/lib/dispatch-rider/logging/text_formatter_spec.rb
241
252
  - spec/lib/dispatch-rider/message_spec.rb
242
253
  - spec/lib/dispatch-rider/notification_services/aws_sns_spec.rb
243
254
  - spec/lib/dispatch-rider/notification_services/base_spec.rb