banter 1.4.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/.travis.yml +1 -1
- data/Gemfile +1 -4
- data/README.md +0 -33
- data/Rakefile +0 -28
- data/banter.gemspec +2 -5
- data/lib/banter.rb +1 -1
- data/lib/banter/configuration.rb +2 -4
- data/lib/banter/notifier.rb +16 -0
- data/lib/banter/publisher.rb +1 -1
- data/lib/banter/railtie.rb +0 -4
- data/lib/banter/server/client_queue_listener.rb +4 -37
- data/lib/banter/server/rabbit_mq_subscriber.rb +6 -6
- data/lib/banter/server/subscriber_server.rb +0 -13
- data/lib/banter/version.rb +1 -1
- data/spec/banter/notifier_spec.rb +40 -0
- data/spec/banter/server/client_queue_listener_spec.rb +36 -84
- data/spec/banter/server/rabbitmq_subscriber_spec.rb +14 -10
- data/spec/banter/server/subscriber_server_spec.rb +0 -60
- data/spec/banter/subscriber_spec.rb +0 -81
- data/spec/spec_helper.rb +1 -8
- data/spec/support/test_notifier.rb +17 -0
- metadata +33 -100
- data/.ruby-version +0 -1
- data/lib/banter/web.rb +0 -34
- data/lib/banter/web/application.rb +0 -85
- data/lib/banter/web/helpers.rb +0 -13
- data/lib/banter/web/models/banter_message.rb +0 -124
- data/lib/banter/web/models/banter_worker.rb +0 -72
- data/lib/banter/web/serializers/banter_message_serializer.rb +0 -35
- data/lib/banter/web/serializers/banter_worker_serializer.rb +0 -40
- data/lib/banter/web/serializers/subscriber_serializer.rb +0 -26
- data/spec/banter/web/application_spec.rb +0 -181
- data/spec/banter/web/serializers/banter_message_serializer_spec.rb +0 -42
- data/spec/banter/web/serializers/banter_worker_serializer_spec.rb +0 -44
- data/spec/factories/banter_messages.rb +0 -28
- data/spec/factories/banter_workers.rb +0 -17
- data/spec/mongoid.yml +0 -7
- data/web/assets/javascripts/banter.js +0 -449
- data/web/assets/javascripts/dashboard_app/app.coffee +0 -4
- data/web/assets/javascripts/dashboard_app/controllers/message_controller.coffee +0 -28
- data/web/assets/javascripts/dashboard_app/controllers/messages_controller.coffee +0 -58
- data/web/assets/javascripts/dashboard_app/controllers/subscribers_controller.coffee +0 -25
- data/web/assets/javascripts/dashboard_app/controllers/worker_controller.coffee +0 -30
- data/web/assets/javascripts/dashboard_app/controllers/workers_list_controller.coffee +0 -28
- data/web/assets/javascripts/dashboard_app/routes.coffee +0 -82
- data/web/assets/javascripts/dashboard_app/services/common_methods_service.coffee +0 -6
- data/web/assets/javascripts/dashboard_app/services/message_methods_service.coffee +0 -18
- data/web/assets/javascripts/dashboard_app/services/messages_service.coffee +0 -17
- data/web/assets/javascripts/dashboard_app/services/subscribers_service.coffee +0 -8
- data/web/assets/javascripts/dashboard_app/services/worker_methods_service.coffee +0 -11
- data/web/assets/javascripts/dashboard_app/services/worker_service.coffee +0 -15
- data/web/assets/javascripts/ng-prettyjson.js +0 -15
- data/web/assets/stylesheets/banter.css +0 -78
- data/web/views/_message.haml +0 -74
- data/web/views/_messages.haml +0 -77
- data/web/views/_subscribers.haml +0 -22
- data/web/views/_worker.haml +0 -52
- data/web/views/_workers_list.haml +0 -35
- data/web/views/index.haml +0 -19
- data/web/views/layout.haml +0 -51
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c03308431cc8b88c19125424eb68bb908a3d4371
|
4
|
+
data.tar.gz: 40e04814acf8a8bf45890e02340eadf06442a6c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df196c9fa5a9ba80aedf5bddf922f6b148522cb2a1c57b8c953ff180d87d7021d4b12f708d667e8b31edd0df1dbfd5abb1ca0f70dae448bfed5da9c32be0012e
|
7
|
+
data.tar.gz: c192baefaf7eb97f48f0cf3e879f727e8087cd118f33f626556bcf4363520460824d454eb9fb400476e3f707c57c789ebbf79beaec3f1cef90968334ef0a3111
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
@@ -3,14 +3,11 @@ source 'https://rubygems.org'
|
|
3
3
|
# Specify your gem's dependencies in banter.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem 'coffee-script'
|
7
6
|
gem 'json'
|
8
7
|
group :test do
|
9
8
|
gem 'rack-test'
|
10
9
|
gem 'rspec-its'
|
11
|
-
gem 'sinatra'
|
12
|
-
gem 'haml'
|
13
|
-
gem 'mongoid', "~>4.0"
|
14
10
|
gem 'timecop'
|
11
|
+
gem 'awesome_print', '~> 1.6', '>= 1.6.1'
|
15
12
|
gem "factory_girl", "~> 4.0"
|
16
13
|
end
|
data/README.md
CHANGED
@@ -108,39 +108,6 @@ class UserWelcomeSubscriber < Banter::Subscriber
|
|
108
108
|
end
|
109
109
|
```
|
110
110
|
|
111
|
-
### Dashboards!!!
|
112
|
-
|
113
|
-
Banter provides dashboards that can be easily enabled in any Rack application.
|
114
|
-
|
115
|
-
For a Rails application
|
116
|
-
|
117
|
-
```
|
118
|
-
# config/application.rb
|
119
|
-
config.banter.web_enabled = true
|
120
|
-
```
|
121
|
-
|
122
|
-
```
|
123
|
-
#config/routes.rb
|
124
|
-
mount Banter::Web::Application => '/banter'
|
125
|
-
```
|
126
|
-
|
127
|
-
or
|
128
|
-
|
129
|
-
```
|
130
|
-
#config.routes.rb
|
131
|
-
authenticate :admin do
|
132
|
-
mount Banter::Web::Application => '/banter'
|
133
|
-
end
|
134
|
-
```
|
135
|
-
|
136
|
-
Dashboards currently use Mongo DB (Mongoid gem) to store data, so the following gems should be added to your gemfile
|
137
|
-
```
|
138
|
-
gem 'mongoid'
|
139
|
-
gem 'haml'
|
140
|
-
gem 'sinatra'
|
141
|
-
```
|
142
|
-
|
143
|
-
|
144
111
|
## Contributing
|
145
112
|
|
146
113
|
1. Fork it
|
data/Rakefile
CHANGED
@@ -6,31 +6,3 @@ begin
|
|
6
6
|
task :default => :spec
|
7
7
|
end
|
8
8
|
|
9
|
-
begin
|
10
|
-
require 'coffee-script'
|
11
|
-
|
12
|
-
namespace :js do
|
13
|
-
def add_javascript(js_file, output_file)
|
14
|
-
js_file_souce = File.read("#{File.dirname(__FILE__)}/web/assets/javascripts/#{js_file}.js")
|
15
|
-
output_file.puts js_file_souce
|
16
|
-
end
|
17
|
-
|
18
|
-
desc "compile coffee-scripts from ./assets/javascripts"
|
19
|
-
task :compile do
|
20
|
-
source = "#{File.dirname(__FILE__)}/web/assets/javascripts/**/*.coffee"
|
21
|
-
target = "#{File.dirname(__FILE__)}/web/assets/javascripts/banter.js"
|
22
|
-
file = File.open(target, 'w+')
|
23
|
-
|
24
|
-
add_javascript("ng-prettyjson", file)
|
25
|
-
|
26
|
-
Dir.glob(source) do |cf|
|
27
|
-
puts cf
|
28
|
-
file.puts CoffeeScript.compile File.read(cf)
|
29
|
-
end
|
30
|
-
|
31
|
-
file.close
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
|
36
|
-
end
|
data/banter.gemspec
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
lib = File.expand_path('../lib', __FILE__)
|
3
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
4
|
|
5
|
-
# require all files in the folder?
|
6
5
|
require 'banter/version'
|
7
6
|
|
8
7
|
Gem::Specification.new do |spec|
|
@@ -20,13 +19,11 @@ Gem::Specification.new do |spec|
|
|
20
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
20
|
spec.require_paths = ["lib"]
|
22
21
|
|
23
|
-
spec.add_development_dependency "bundler", "
|
22
|
+
spec.add_development_dependency "bundler", ">= 1.3"
|
24
23
|
spec.add_development_dependency "rake", "~> 10.0"
|
25
24
|
spec.add_development_dependency "rspec", "~> 3.0.0"
|
26
|
-
spec.
|
27
|
-
spec.add_runtime_dependency "awesome_print", "~> 1.2.0"
|
25
|
+
spec.add_development_dependency "awesome_print", '>= 1.6.1'
|
28
26
|
spec.add_runtime_dependency "bunny", "~> 1.2"
|
29
|
-
spec.add_runtime_dependency "airbrake", "~> 3.1"
|
30
27
|
spec.add_runtime_dependency "hashie", ">= 1.2"
|
31
28
|
spec.add_runtime_dependency "json", ">= 1.8"
|
32
29
|
spec.add_runtime_dependency "celluloid", ">= 0.15"
|
data/lib/banter.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
require "active_support/all"
|
2
2
|
require "bunny"
|
3
3
|
require "yaml"
|
4
|
-
require "airbrake"
|
5
4
|
|
6
5
|
require "banter/configuration"
|
7
6
|
require "banter/context"
|
@@ -14,6 +13,7 @@ require "banter/version"
|
|
14
13
|
require "banter/exceptions/payload_validation_error"
|
15
14
|
require 'banter/server'
|
16
15
|
require 'banter/subscriber'
|
16
|
+
require 'banter/notifier'
|
17
17
|
require 'banter/delay_publish_model'
|
18
18
|
|
19
19
|
if defined?(Rails::Railtie)
|
data/lib/banter/configuration.rb
CHANGED
@@ -29,6 +29,8 @@ module Banter
|
|
29
29
|
|
30
30
|
mattr_accessor :logger
|
31
31
|
|
32
|
+
mattr_accessor :notifier
|
33
|
+
|
32
34
|
# RabbitMQ push and subscribe logging toggle
|
33
35
|
# @default true
|
34
36
|
mattr_accessor :logging_enabled
|
@@ -44,10 +46,6 @@ module Banter
|
|
44
46
|
mattr_accessor :batch_messages
|
45
47
|
@@batch_messages = false
|
46
48
|
|
47
|
-
# Enable web monitoring
|
48
|
-
# @default false
|
49
|
-
mattr_accessor :web_enabled
|
50
|
-
@@web_enabled = false
|
51
49
|
|
52
50
|
mattr_accessor :application_name
|
53
51
|
@@application_name = nil
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Banter
|
2
|
+
module Notifier
|
3
|
+
def self.notify(error, params_hash)
|
4
|
+
::Banter::Configuration.notifier.notify(error, params_hash)
|
5
|
+
end
|
6
|
+
|
7
|
+
class StdOutNotifier
|
8
|
+
def self.notify(error, params_hash)
|
9
|
+
STDOUT.puts("Error caught: #{error}, #{params_hash}")
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# Is this legit to just load up and assign as default for now?
|
16
|
+
::Banter::Configuration.notifier ||= Banter::Notifier::StdOutNotifier
|
data/lib/banter/publisher.rb
CHANGED
@@ -52,7 +52,7 @@ module Banter
|
|
52
52
|
@publisher = @channel.send(@exchange_type, @exchange, :durable => true, :auto_delete => false)
|
53
53
|
|
54
54
|
rescue => e
|
55
|
-
|
55
|
+
::Banter::Notifier.notify(e, parameters: { message: e.message }, environment_name: ENV['RAILS_ENV'])
|
56
56
|
return
|
57
57
|
end
|
58
58
|
|
data/lib/banter/railtie.rb
CHANGED
@@ -30,33 +30,17 @@ module Banter
|
|
30
30
|
Banter::RabbitLogger.log(::Logger::DEBUG, "Message received by listener on #{worker_class.name} with payload: #{envelope[:payload]}")
|
31
31
|
worker = worker_class.new(delivery_info, properties, envelope[:context], envelope)
|
32
32
|
payload = envelope[:payload]
|
33
|
-
track_message_received(worker, payload)
|
34
33
|
worker.perform!(payload)
|
35
|
-
track_message_successful
|
36
34
|
clear_dead_letter(worker_class.config.dead_letter_queue_name, envelope)
|
37
35
|
rescue ::Banter::PayloadValidationError => banter_error
|
38
|
-
track_message_failed(banter_error, false)
|
39
36
|
Banter::RabbitLogger.log(::Logger::ERROR, { worker: worker_class.name, message: banter_error.message, envelope: envelope })
|
40
|
-
|
41
|
-
|
42
|
-
info: delivery_info,
|
43
|
-
properties: properties,
|
44
|
-
context: envelope[:context],
|
45
|
-
payload: envelope[:payload],
|
46
|
-
message: "Validation error for #{worker_class.name}"
|
47
|
-
})
|
37
|
+
|
38
|
+
::Banter::Notifier.notify(banter_error, { delivery_info: delivery_info, properties: properties, envelope: envelope})
|
48
39
|
raise banter_error
|
49
40
|
rescue => e
|
50
|
-
track_message_failed(e, true)
|
51
41
|
Banter::RabbitLogger.log(::Logger::ERROR, "Failed message for #{worker_class.name} #{e.message}")
|
52
|
-
|
53
|
-
|
54
|
-
info: delivery_info,
|
55
|
-
properties: properties,
|
56
|
-
context: envelope[:context],
|
57
|
-
payload: envelope[:payload],
|
58
|
-
message: "Failed perform for #{worker_class.name}"
|
59
|
-
})
|
42
|
+
|
43
|
+
::Banter::Notifier.notify(e, { delivery_info: delivery_info, properties: properties, envelope: envelope})
|
60
44
|
raise e
|
61
45
|
end
|
62
46
|
|
@@ -67,23 +51,6 @@ module Banter
|
|
67
51
|
end
|
68
52
|
end
|
69
53
|
|
70
|
-
protected
|
71
|
-
|
72
|
-
def track_message_successful
|
73
|
-
return unless Banter::Configuration.web_enabled
|
74
|
-
BanterMessage.message_successful
|
75
|
-
end
|
76
|
-
|
77
|
-
def track_message_failed(error, errored = true)
|
78
|
-
return unless Banter::Configuration.web_enabled
|
79
|
-
status = errored ? BanterMessage::STATUS_ERROR : BanterMessage::STATUS_VALIDATION_FAILED
|
80
|
-
BanterMessage.message_failed(error, status)
|
81
|
-
end
|
82
|
-
|
83
|
-
def track_message_received(worker, payload)
|
84
|
-
return unless Banter::Configuration.web_enabled
|
85
|
-
BanterMessage.message_received(worker_class, worker, payload)
|
86
|
-
end
|
87
54
|
end
|
88
55
|
end
|
89
56
|
end
|
@@ -28,7 +28,6 @@ module Banter
|
|
28
28
|
elsif @topic.present?
|
29
29
|
@routing_key = "#{@topic}.#"
|
30
30
|
end
|
31
|
-
|
32
31
|
end
|
33
32
|
|
34
33
|
def start(&block)
|
@@ -37,7 +36,7 @@ module Banter
|
|
37
36
|
@connection.start
|
38
37
|
rescue => e
|
39
38
|
Banter::RabbitLogger.log(Logger::ERROR, "Cannot connect to rabbitmq")
|
40
|
-
|
39
|
+
::Banter::Notifier.notify(e, parameters: { message: e.message, what_happened: "RabbitMQ unreachable!" }, environment_name: environment)
|
41
40
|
raise e
|
42
41
|
end
|
43
42
|
|
@@ -70,7 +69,7 @@ module Banter
|
|
70
69
|
|
71
70
|
if delivery_info[:redelivered]
|
72
71
|
e = StandardError.new("PubSub Message redelivery")
|
73
|
-
|
72
|
+
::Banter::Notifier.notify(e, parameters: { info: delivery_info, props: properties, contents: contents }, backtrace: caller)
|
74
73
|
end
|
75
74
|
|
76
75
|
Banter::RabbitLogger.log_receive(delivery_info[:routing_key], envelope)
|
@@ -89,14 +88,14 @@ module Banter
|
|
89
88
|
# Does not get put back on the queue, and instead, will need to be processed either by the log parser
|
90
89
|
# later or by dead letter exchange
|
91
90
|
@channel.reject(token, false)
|
92
|
-
|
91
|
+
::Banter::Notifier.notify(e, parameters: { delivery_info: delivery_info, properties: properties, contents: contents, error: e.message }, environment_name: environment)
|
93
92
|
end
|
94
93
|
end
|
95
94
|
|
96
95
|
def notify_error(error, consumer)
|
97
96
|
Banter::RabbitLogger.log(Logger::WARN, "Error with the message: #{error.message}: #{consumer}")
|
98
97
|
Banter::RabbitLogger.log(Logger::WARN, "#{caller.inspect}")
|
99
|
-
|
98
|
+
::Banter::Notifier.notify(error, parameters: { consumer: consumer, error: error.message }, environment_name: environment)
|
100
99
|
end
|
101
100
|
|
102
101
|
def teardown
|
@@ -104,13 +103,14 @@ module Banter
|
|
104
103
|
@consumer.cancel if @consumer.present?
|
105
104
|
@connection.close if @connection.present?
|
106
105
|
rescue => e
|
107
|
-
|
106
|
+
::Banter::Notifier.notify(e, parameters: { error: e.message }, environment_name: environment)
|
108
107
|
end
|
109
108
|
end
|
110
109
|
|
111
110
|
def environment
|
112
111
|
ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
|
113
112
|
end
|
113
|
+
|
114
114
|
end
|
115
115
|
end
|
116
116
|
end
|
@@ -1,7 +1,6 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'celluloid/autostart'
|
3
3
|
require 'celluloid/io'
|
4
|
-
require 'awesome_print'
|
5
4
|
require 'active_support/all'
|
6
5
|
require 'optparse'
|
7
6
|
require 'fileutils'
|
@@ -29,7 +28,6 @@ module Banter
|
|
29
28
|
|
30
29
|
def start
|
31
30
|
set_information
|
32
|
-
register_workers
|
33
31
|
start_workers
|
34
32
|
handle_interrupts
|
35
33
|
handle_teardown
|
@@ -37,16 +35,10 @@ module Banter
|
|
37
35
|
stop_worker
|
38
36
|
end
|
39
37
|
|
40
|
-
def register_workers
|
41
|
-
return unless Banter::Configuration.web_enabled
|
42
|
-
BanterWorker.worker_started
|
43
|
-
end
|
44
|
-
|
45
38
|
private
|
46
39
|
|
47
40
|
def handle_teardown
|
48
41
|
::Banter::RabbitLogger.log_service("all_services", "Starting shutdown of all services")
|
49
|
-
unregister_current_worker
|
50
42
|
|
51
43
|
workers.each do |worker|
|
52
44
|
::Banter::RabbitLogger.log_service("all_services", "Tearing down worker: #{worker.worker_class.name}")
|
@@ -59,11 +51,6 @@ module Banter
|
|
59
51
|
end
|
60
52
|
end
|
61
53
|
|
62
|
-
def unregister_current_worker
|
63
|
-
return unless Banter::Configuration.web_enabled
|
64
|
-
BanterWorker.worker_stopped
|
65
|
-
end
|
66
|
-
|
67
54
|
def handle_interrupts
|
68
55
|
thread = Thread.current
|
69
56
|
interrupts = ["HUP", "INT", "QUIT", "ABRT", "TERM"]
|
data/lib/banter/version.rb
CHANGED
@@ -0,0 +1,40 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'bunny'
|
3
|
+
|
4
|
+
|
5
|
+
describe Banter::Notifier do
|
6
|
+
|
7
|
+
describe "self.notify" do
|
8
|
+
before do
|
9
|
+
notifier
|
10
|
+
prehook
|
11
|
+
Banter::Configuration.application_name = "TestSuite"
|
12
|
+
subject
|
13
|
+
end
|
14
|
+
|
15
|
+
let(:error) { StandardError.new("TestStandardError") }
|
16
|
+
let(:hash_error) { { keyerr1: "value1err" } }
|
17
|
+
let(:prehook) { }
|
18
|
+
|
19
|
+
subject { ::Banter::Notifier.notify(error, hash_error) }
|
20
|
+
context "without a notification class" do
|
21
|
+
let(:notifier) { }
|
22
|
+
let(:prehook) {
|
23
|
+
allow(STDOUT).to receive(:puts).and_call_original
|
24
|
+
::Banter::Configuration.notifier = Banter::Notifier::StdOutNotifier
|
25
|
+
}
|
26
|
+
it { expect(STDOUT).to have_received(:puts).with(/Error caught/)}
|
27
|
+
|
28
|
+
end
|
29
|
+
|
30
|
+
context "with a notification class" do
|
31
|
+
let(:notifier) {
|
32
|
+
Banter::Configuration.notifier = TestNotifier
|
33
|
+
}
|
34
|
+
|
35
|
+
it { expect(TestNotifier.instance.error).to eq(error) }
|
36
|
+
it { expect(TestNotifier.instance.hash).to eq(hash_error) }
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
3
|
class TestSubscriber < Banter::Subscriber
|
5
4
|
subscribe_to "some.test.key"
|
6
5
|
end
|
@@ -27,35 +26,9 @@ describe Banter::Server::ClientQueueListener do
|
|
27
26
|
let(:context_before) { }
|
28
27
|
let(:validators) { [] }
|
29
28
|
let(:banter_worker) { FactoryGirl.create(:banter_worker, process_name: 'test') }
|
30
|
-
let(:enable_banter_web) {
|
31
|
-
Banter::Configuration.web_enabled = true
|
32
|
-
allow(BanterWorker).to receive(:current).and_return(banter_worker)
|
33
|
-
}
|
34
29
|
let!(:application_name) { "testapplication" }
|
35
|
-
let(:banter_message) { BanterMessage.last }
|
36
30
|
let(:subscriber_options) {{}}
|
37
31
|
|
38
|
-
after(:each) { Banter::Configuration.web_enabled = false }
|
39
|
-
|
40
|
-
def self.banter_message_fields_are_correct(status, error_message = nil)
|
41
|
-
it { expect(BanterMessage.count).to eq 1 }
|
42
|
-
it { expect(banter_message.subscriber_class).to eq('Klass') }
|
43
|
-
it { expect(banter_message.queue_name).to eq("test.foo_#{application_name}") }
|
44
|
-
it { expect(banter_message.subscribed_key).to eq('test.foo') }
|
45
|
-
it { expect(banter_message.payload).to eq({ "hello" => "moto" }) }
|
46
|
-
it { expect(banter_message.started_at.to_s).to eq(Time.now.to_s) }
|
47
|
-
it { expect(banter_message.done_at.to_s).to eq(Time.now.to_s) }
|
48
|
-
it { expect(banter_message.worker_id).to eq(BanterWorker.current.id) }
|
49
|
-
it { expect(banter_message.status).to eq(status) }
|
50
|
-
if error_message
|
51
|
-
it { expect(banter_message.error_message).to eq(error_message) }
|
52
|
-
it { expect(banter_message.error_backtrace).not_to be_blank }
|
53
|
-
else
|
54
|
-
it { expect(banter_message.error_message).to be_nil }
|
55
|
-
it { expect(banter_message.error_backtrace).to be_nil }
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
32
|
before do
|
60
33
|
Banter::Configuration.application_name = application_name
|
61
34
|
context_before
|
@@ -88,34 +61,17 @@ describe Banter::Server::ClientQueueListener do
|
|
88
61
|
instance
|
89
62
|
}
|
90
63
|
|
91
|
-
|
92
64
|
before do
|
93
|
-
|
65
|
+
safe_call unless respond_to? :no_call
|
94
66
|
end
|
95
67
|
|
96
|
-
context "
|
97
|
-
|
98
|
-
|
99
|
-
it { should_not raise_exception }
|
100
|
-
end
|
101
|
-
|
102
|
-
context "call" do
|
103
|
-
it { expect(klass_instance).to have_received(:perform!).with(payload) }
|
104
|
-
it { expect(BanterMessage.count).to eq(0) }
|
105
|
-
end
|
68
|
+
context "test exception" do
|
69
|
+
let(:no_call) { true }
|
70
|
+
it { should_not raise_exception }
|
106
71
|
end
|
107
72
|
|
108
|
-
context "
|
109
|
-
|
110
|
-
|
111
|
-
context "test exception" do
|
112
|
-
let(:no_call) { true }
|
113
|
-
it { should_not raise_exception }
|
114
|
-
end
|
115
|
-
|
116
|
-
context "call" do
|
117
|
-
banter_message_fields_are_correct(BanterMessage::STATUS_SUCCESS)
|
118
|
-
end
|
73
|
+
context "call" do
|
74
|
+
it { expect(klass_instance).to have_received(:perform!).with(payload) }
|
119
75
|
end
|
120
76
|
|
121
77
|
end
|
@@ -128,27 +84,31 @@ describe Banter::Server::ClientQueueListener do
|
|
128
84
|
}
|
129
85
|
instance
|
130
86
|
}
|
87
|
+
let(:prehook) {}
|
131
88
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
it { should raise_exception }
|
137
|
-
it { expect(BanterMessage.count).to eq(0) }
|
89
|
+
before do
|
90
|
+
prehook
|
91
|
+
allow(Banter::RabbitLogger).to receive(:log).and_call_original
|
92
|
+
safe_call
|
138
93
|
end
|
139
94
|
|
140
|
-
context "
|
141
|
-
let(:
|
95
|
+
context "without a notifier" do
|
96
|
+
let(:prehook) {
|
97
|
+
allow(STDOUT).to receive(:puts).and_call_original
|
98
|
+
}
|
99
|
+
it { expect(@raised_error).not_to be_nil }
|
100
|
+
end
|
142
101
|
|
143
|
-
|
144
|
-
|
145
|
-
|
102
|
+
context "with a notifier" do
|
103
|
+
let(:prehook) {
|
104
|
+
Banter::Configuration.notifier = TestNotifier
|
105
|
+
allow(TestNotifier).to receive(:notify).and_call_original
|
106
|
+
}
|
146
107
|
|
147
|
-
it {
|
148
|
-
it
|
149
|
-
|
150
|
-
|
151
|
-
banter_message_fields_are_correct(BanterMessage::STATUS_ERROR, 'test exception')
|
108
|
+
it { expect(@raised_error).not_to be_nil }
|
109
|
+
it { expect(TestNotifier).to have_received(:notify) }
|
110
|
+
it { expect(TestNotifier.instance.error.to_s).to match(/test exception/) }
|
111
|
+
it { expect(TestNotifier.instance.hash.keys).to match_array([:delivery_info, :envelope, :properties]) }
|
152
112
|
end
|
153
113
|
end
|
154
114
|
|
@@ -158,31 +118,23 @@ describe Banter::Server::ClientQueueListener do
|
|
158
118
|
allow(instance).to receive(:perform!).and_raise(Banter::PayloadValidationError.new("validation failed"))
|
159
119
|
instance
|
160
120
|
}
|
161
|
-
|
162
121
|
let(:result) { subject.call }
|
122
|
+
let(:prehook) {
|
123
|
+
Banter::Configuration.notifier = TestNotifier
|
124
|
+
allow(TestNotifier).to receive(:notify).and_call_original
|
125
|
+
}
|
126
|
+
|
163
127
|
|
164
128
|
before do
|
129
|
+
prehook
|
165
130
|
safe_call
|
166
131
|
end
|
167
132
|
|
168
133
|
let!(:validators) { [lambda { |payload| false }] }
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
end
|
174
|
-
|
175
|
-
context "web enabled" do
|
176
|
-
let(:context_before) do
|
177
|
-
allow(Airbrake).to receive(:notify)
|
178
|
-
enable_banter_web
|
179
|
-
end
|
180
|
-
|
181
|
-
it { expect(Airbrake).to have_received(:notify) }
|
182
|
-
it { should raise_exception }
|
183
|
-
it { expect(klass_instance).to have_received(:perform!).with(payload) }
|
184
|
-
banter_message_fields_are_correct(BanterMessage::STATUS_VALIDATION_FAILED, "validation failed")
|
185
|
-
end
|
134
|
+
it { should raise_exception }
|
135
|
+
it { expect(TestNotifier).to have_received(:notify) }
|
136
|
+
it { expect(TestNotifier.instance.error.to_s).to match(/validation failed/) }
|
137
|
+
it { expect(TestNotifier.instance.hash.keys).to match_array([:delivery_info, :envelope, :properties]) }
|
186
138
|
end
|
187
139
|
|
188
140
|
context "reprocessing message" do
|