hutch 0.17.0 → 0.18.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/.travis.yml +4 -0
- data/CHANGELOG.md +23 -1
- data/README.md +7 -0
- data/hutch.gemspec +7 -1
- data/lib/hutch.rb +1 -1
- data/lib/hutch/adapter.rb +11 -0
- data/lib/hutch/adapters/bunny.rb +33 -0
- data/lib/hutch/adapters/march_hare.rb +37 -0
- data/lib/hutch/broker.rb +71 -53
- data/lib/hutch/config.rb +3 -0
- data/lib/hutch/version.rb +1 -1
- data/lib/hutch/worker.rb +33 -4
- data/spec/hutch/broker_spec.rb +62 -10
- data/spec/spec_helper.rb +6 -1
- metadata +7 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ae290b72e28ca5ca72f8014fe5688e35b4c31716
|
4
|
+
data.tar.gz: 2a817eece4ab761d6558255395e123d5cea19ea0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b929abefa84452c0b5a74fc2dcfc5f2918fb752d80f97b77e97cf4d0fbfad99e119cd09f3251f17edf1450ee7ccc063a76efaa9e31d318526aabf5a147779b84
|
7
|
+
data.tar.gz: c5c04b649c3ea2333ff86273d7d17a1d843a02e782bd981d19ef2ea4025286761b4b96fd8200026ce2f503108d588c0aa61f204997632f02ac467ac5fa4633c3
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,28 @@
|
|
1
1
|
## 0.18.0 — (unreleased)
|
2
2
|
|
3
|
-
|
3
|
+
### JRuby Support (Using March Hare)
|
4
|
+
|
5
|
+
Hutch will now use March Hare when running on JRuby.
|
6
|
+
This will yield significant throughput and core utilisation
|
7
|
+
improvements for workloads with many and/or busy consumers.
|
8
|
+
|
9
|
+
Contributed by Teodor Pripoae.
|
10
|
+
|
11
|
+
|
12
|
+
### Configurable Consumer Thread Pool Size
|
13
|
+
|
14
|
+
`:consumer_pool_size` is a new option (defaults to `1`) which defines
|
15
|
+
Bunny consumer work pool size.
|
16
|
+
|
17
|
+
Contributed by Derek Kastner.
|
18
|
+
|
19
|
+
### Bunny Logger Option
|
20
|
+
|
21
|
+
`:client_logger` is a new option that allows
|
22
|
+
for configuring loggerd used by Bunny, the underlying
|
23
|
+
RabbitMQ client library.
|
24
|
+
|
25
|
+
Contributed by Nate Salisbury.
|
4
26
|
|
5
27
|
|
6
28
|
## 0.17.0 — July 19th, 2015
|
data/README.md
CHANGED
@@ -116,6 +116,13 @@ logger rather than `stdout`, add this to `config/initializers/hutch.rb`
|
|
116
116
|
Hutch::Logging.logger = Rails.logger
|
117
117
|
```
|
118
118
|
|
119
|
+
A logger can be set for the client by adding this config before calling `Hutch.connect`
|
120
|
+
|
121
|
+
```ruby
|
122
|
+
client_logger = Logger.new("/path/to/bunny.log")
|
123
|
+
Hutch::Config.set(:client_logger, client_logger)
|
124
|
+
```
|
125
|
+
|
119
126
|
See this [RabbitMQ tutorial on topic exchanges](http://www.rabbitmq.com/tutorials/tutorial-five-ruby.html)
|
120
127
|
to learn more.
|
121
128
|
|
data/hutch.gemspec
CHANGED
@@ -1,7 +1,13 @@
|
|
1
1
|
require File.expand_path('../lib/hutch/version', __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
|
-
|
4
|
+
if defined?(JRUBY_VERSION)
|
5
|
+
gem.platform = 'java'
|
6
|
+
gem.add_runtime_dependency 'march_hare', '>= 2.11.0'
|
7
|
+
else
|
8
|
+
gem.platform = Gem::Platform::RUBY
|
9
|
+
gem.add_runtime_dependency 'bunny', '>= 1.7.0'
|
10
|
+
end
|
5
11
|
gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
|
6
12
|
gem.add_runtime_dependency 'multi_json', '~> 1.5'
|
7
13
|
gem.add_runtime_dependency 'activesupport', '>= 3.0'
|
data/lib/hutch.rb
CHANGED
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'bunny'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
module Hutch
|
5
|
+
module Adapters
|
6
|
+
class BunnyAdapter
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
DEFAULT_VHOST = Bunny::Session::DEFAULT_VHOST
|
10
|
+
|
11
|
+
ConnectionRefused = Bunny::TCPConnectionFailed
|
12
|
+
PreconditionFailed = Bunny::PreconditionFailed
|
13
|
+
|
14
|
+
def_delegators :@connection, :start, :disconnect, :close, :create_channel, :open?
|
15
|
+
|
16
|
+
def initialize(opts={})
|
17
|
+
@connection = Bunny.new(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.decode_message(delivery_info, properties, payload)
|
21
|
+
[delivery_info, properties, payload]
|
22
|
+
end
|
23
|
+
|
24
|
+
def prefetch_channel(ch, prefetch)
|
25
|
+
ch.prefetch(prefetch) if prefetch
|
26
|
+
end
|
27
|
+
|
28
|
+
def current_timestamp
|
29
|
+
Time.now.to_i
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require 'march_hare'
|
2
|
+
require 'forwardable'
|
3
|
+
|
4
|
+
module Hutch
|
5
|
+
module Adapters
|
6
|
+
class MarchHareAdapter
|
7
|
+
extend Forwardable
|
8
|
+
|
9
|
+
DEFAULT_VHOST = "/"
|
10
|
+
|
11
|
+
ConnectionRefused = MarchHare::ConnectionRefused
|
12
|
+
PreconditionFailed = MarchHare::PreconditionFailed
|
13
|
+
|
14
|
+
def_delegators :@connection, :start, :disconnect, :close, :open?
|
15
|
+
|
16
|
+
def initialize(opts = {})
|
17
|
+
@connection = MarchHare.connect(opts)
|
18
|
+
end
|
19
|
+
|
20
|
+
def self.decode_message(delivery_info, payload)
|
21
|
+
[delivery_info, delivery_info.properties, payload]
|
22
|
+
end
|
23
|
+
|
24
|
+
def prefetch_channel(ch, prefetch)
|
25
|
+
ch.prefetch = prefetch if prefetch
|
26
|
+
end
|
27
|
+
|
28
|
+
def create_channel(n = nil, consumer_pool_size = 1)
|
29
|
+
@connection.create_channel(n)
|
30
|
+
end
|
31
|
+
|
32
|
+
def current_timestamp
|
33
|
+
Time.now
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/hutch/broker.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'bunny'
|
2
1
|
require 'carrot-top'
|
3
2
|
require 'securerandom'
|
4
3
|
require 'hutch/logging'
|
@@ -61,58 +60,22 @@ module Hutch
|
|
61
60
|
end
|
62
61
|
|
63
62
|
def open_connection!
|
64
|
-
if @config[:uri] && !@config[:uri].empty?
|
65
|
-
u = URI.parse(@config[:uri])
|
66
|
-
|
67
|
-
@config[:mq_host] = u.host
|
68
|
-
@config[:mq_port] = u.port
|
69
|
-
@config[:mq_vhost] = u.path.sub(/^\//, "")
|
70
|
-
@config[:mq_username] = u.user
|
71
|
-
@config[:mq_password] = u.password
|
72
|
-
@config[:mq_tls] = u.scheme == "amqps"
|
73
|
-
end
|
74
|
-
|
75
|
-
tls = @config[:mq_tls]
|
76
|
-
host = @config[:mq_host]
|
77
|
-
port = @config.to_hash.fetch(:mq_port, (tls ? 5671 : 5672))
|
78
|
-
vhost = if @config[:mq_vhost] && "" != @config[:mq_vhost]
|
79
|
-
@config[:mq_vhost]
|
80
|
-
else
|
81
|
-
Bunny::Session::DEFAULT_VHOST
|
82
|
-
end
|
83
|
-
username = @config[:mq_username]
|
84
|
-
password = @config[:mq_password]
|
85
|
-
tls_key = @config[:mq_tls_key]
|
86
|
-
tls_cert = @config[:mq_tls_cert]
|
87
|
-
heartbeat = @config[:heartbeat]
|
88
|
-
connection_timeout = @config[:connection_timeout]
|
89
|
-
read_timeout = @config[:read_timeout]
|
90
|
-
write_timeout = @config[:write_timeout]
|
91
|
-
|
92
|
-
scheme = tls ? "amqps" : "amqp"
|
93
|
-
sanitized_uri = "#{scheme}://#{username}@#{host}:#{port}/#{vhost.sub(/^\//, '')}"
|
94
63
|
logger.info "connecting to rabbitmq (#{sanitized_uri})"
|
95
|
-
|
96
|
-
|
97
|
-
username: username, password: password,
|
98
|
-
heartbeat: heartbeat, automatically_recover: true,
|
99
|
-
network_recovery_interval: 1,
|
100
|
-
connection_timeout: connection_timeout,
|
101
|
-
read_timeout: read_timeout,
|
102
|
-
write_timeout: write_timeout)
|
64
|
+
|
65
|
+
@connection = Hutch::Adapter.new(connection_params)
|
103
66
|
|
104
67
|
with_bunny_connection_handler(sanitized_uri) do
|
105
68
|
@connection.start
|
106
69
|
end
|
107
70
|
|
108
|
-
logger.info "connected to RabbitMQ at #{host} as #{username}"
|
71
|
+
logger.info "connected to RabbitMQ at #{connection_params[:host]} as #{connection_params[:username]}"
|
109
72
|
@connection
|
110
73
|
end
|
111
74
|
|
112
75
|
def open_channel!
|
113
|
-
logger.info
|
114
|
-
@channel = connection.create_channel.tap do |ch|
|
115
|
-
|
76
|
+
logger.info "opening rabbitmq channel with pool size #{consumer_pool_size}"
|
77
|
+
@channel = @connection.create_channel(nil, consumer_pool_size).tap do |ch|
|
78
|
+
@connection.prefetch_channel(ch, @config[:channel_prefetch])
|
116
79
|
if @config[:publisher_confirms] || @config[:force_publisher_confirms]
|
117
80
|
logger.info 'enabling publisher confirms'
|
118
81
|
ch.confirm_select
|
@@ -204,12 +167,16 @@ module Hutch
|
|
204
167
|
end
|
205
168
|
|
206
169
|
def stop
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
170
|
+
if defined?(JRUBY_VERSION)
|
171
|
+
channel.close
|
172
|
+
else
|
173
|
+
# Enqueue a failing job that kills the consumer loop
|
174
|
+
channel_work_pool.shutdown
|
175
|
+
# Give `timeout` seconds to jobs that are still being processed
|
176
|
+
channel_work_pool.join(@config[:graceful_exit_timeout])
|
177
|
+
# If after `timeout` they are still running, they are killed
|
178
|
+
channel_work_pool.kill
|
179
|
+
end
|
213
180
|
end
|
214
181
|
|
215
182
|
def requeue(delivery_tag)
|
@@ -233,7 +200,7 @@ module Hutch
|
|
233
200
|
|
234
201
|
non_overridable_properties = {
|
235
202
|
routing_key: routing_key,
|
236
|
-
timestamp:
|
203
|
+
timestamp: @connection.current_timestamp,
|
237
204
|
content_type: 'application/json'
|
238
205
|
}
|
239
206
|
properties[:message_id] ||= generate_id
|
@@ -286,6 +253,54 @@ module Hutch
|
|
286
253
|
end
|
287
254
|
end
|
288
255
|
|
256
|
+
def connection_params
|
257
|
+
parse_uri
|
258
|
+
|
259
|
+
{}.tap do |params|
|
260
|
+
params[:host] = @config[:mq_host]
|
261
|
+
params[:port] = @config[:mq_port]
|
262
|
+
params[:vhost] = if @config[:mq_vhost] && "" != @config[:mq_vhost]
|
263
|
+
@config[:mq_vhost]
|
264
|
+
else
|
265
|
+
Hutch::Adapter::DEFAULT_VHOST
|
266
|
+
end
|
267
|
+
params[:username] = @config[:mq_username]
|
268
|
+
params[:password] = @config[:mq_password]
|
269
|
+
params[:tls] = @config[:mq_tls]
|
270
|
+
params[:tls_key] = @config[:mq_tls_key]
|
271
|
+
params[:tls_cert] = @config[:mq_tls_cert]
|
272
|
+
params[:heartbeat] = @config[:heartbeat]
|
273
|
+
params[:connection_timeout] = @config[:connection_timeout]
|
274
|
+
params[:read_timeout] = @config[:read_timeout]
|
275
|
+
params[:write_timeout] = @config[:write_timeout]
|
276
|
+
|
277
|
+
|
278
|
+
params[:automatically_recover] = true
|
279
|
+
params[:network_recovery_interval] = 1
|
280
|
+
|
281
|
+
params[:client_logger] = @config[:client_logger] if @config[:client_logger]
|
282
|
+
end
|
283
|
+
end
|
284
|
+
|
285
|
+
def parse_uri
|
286
|
+
return unless @config[:uri] && !@config[:uri].empty?
|
287
|
+
|
288
|
+
u = URI.parse(@config[:uri])
|
289
|
+
|
290
|
+
@config[:mq_host] = u.host
|
291
|
+
@config[:mq_port] = u.port
|
292
|
+
@config[:mq_vhost] = u.path.sub(/^\//, "")
|
293
|
+
@config[:mq_username] = u.user
|
294
|
+
@config[:mq_password] = u.password
|
295
|
+
end
|
296
|
+
|
297
|
+
def sanitized_uri
|
298
|
+
p = connection_params
|
299
|
+
scheme = p[:tls] ? "amqps" : "amqp"
|
300
|
+
|
301
|
+
"#{scheme}://#{p[:username]}@#{p[:host]}:#{p[:port]}/#{p[:vhost].sub(/^\//, '')}"
|
302
|
+
end
|
303
|
+
|
289
304
|
def with_authentication_error_handler
|
290
305
|
yield
|
291
306
|
rescue Net::HTTPServerException => ex
|
@@ -306,7 +321,7 @@ module Hutch
|
|
306
321
|
|
307
322
|
def with_bunny_precondition_handler(item)
|
308
323
|
yield
|
309
|
-
rescue
|
324
|
+
rescue Hutch::Adapter::PreconditionFailed => ex
|
310
325
|
logger.error ex.message
|
311
326
|
s = "RabbitMQ responded with 406 Precondition Failed when creating this #{item}. " +
|
312
327
|
"Perhaps it is being redeclared with non-matching attributes"
|
@@ -315,7 +330,7 @@ module Hutch
|
|
315
330
|
|
316
331
|
def with_bunny_connection_handler(uri)
|
317
332
|
yield
|
318
|
-
rescue
|
333
|
+
rescue Hutch::Adapter::ConnectionRefused => ex
|
319
334
|
logger.error "amqp connection error: #{ex.message.downcase}"
|
320
335
|
raise ConnectionError.new("couldn't connect to rabbitmq at #{uri}. Check your configuration, network connectivity and RabbitMQ logs.")
|
321
336
|
end
|
@@ -328,6 +343,10 @@ module Hutch
|
|
328
343
|
@channel.work_pool
|
329
344
|
end
|
330
345
|
|
346
|
+
def consumer_pool_size
|
347
|
+
@config[:consumer_pool_size]
|
348
|
+
end
|
349
|
+
|
331
350
|
def generate_id
|
332
351
|
SecureRandom.uuid
|
333
352
|
end
|
@@ -337,4 +356,3 @@ module Hutch
|
|
337
356
|
end
|
338
357
|
end
|
339
358
|
end
|
340
|
-
|
data/lib/hutch/config.rb
CHANGED
data/lib/hutch/version.rb
CHANGED
data/lib/hutch/worker.rb
CHANGED
@@ -21,9 +21,20 @@ module Hutch
|
|
21
21
|
# Set up signal handlers for graceful shutdown
|
22
22
|
register_signal_handlers
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
24
|
+
main_loop
|
25
|
+
end
|
26
|
+
|
27
|
+
def main_loop
|
28
|
+
if defined?(JRUBY_VERSION)
|
29
|
+
# Binds shutdown listener to notify main thread if channel was closed
|
30
|
+
bind_shutdown_handler
|
31
|
+
|
32
|
+
handle_signals until shutdown_not_called?(0.1)
|
33
|
+
else
|
34
|
+
# Take a break from Thread#join every 0.1 seconds to check if we've
|
35
|
+
# been sent any signals
|
36
|
+
handle_signals until @broker.wait_on_threads(0.1)
|
37
|
+
end
|
27
38
|
end
|
28
39
|
|
29
40
|
# Register handlers for SIG{QUIT,TERM,INT} to shut down the worker
|
@@ -53,6 +64,23 @@ module Hutch
|
|
53
64
|
@broker.stop
|
54
65
|
end
|
55
66
|
|
67
|
+
# Binds shutdown handler, called if channel is closed or network Failed
|
68
|
+
def bind_shutdown_handler
|
69
|
+
@broker.channel.on_shutdown do
|
70
|
+
Thread.main[:shutdown_received] = true
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# Checks if shutdown handler was called, then sleeps for interval
|
75
|
+
def shutdown_not_called?(interval)
|
76
|
+
if Thread.main[:shutdown_received]
|
77
|
+
true
|
78
|
+
else
|
79
|
+
sleep(interval)
|
80
|
+
false
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
56
84
|
# Set up the queues for each of the worker's consumers.
|
57
85
|
def setup_queues
|
58
86
|
logger.info 'setting up queues'
|
@@ -65,7 +93,8 @@ module Hutch
|
|
65
93
|
queue = @broker.queue(consumer.get_queue_name, consumer.get_arguments)
|
66
94
|
@broker.bind_queue(queue, consumer.routing_keys)
|
67
95
|
|
68
|
-
queue.subscribe(manual_ack: true) do |
|
96
|
+
queue.subscribe(manual_ack: true) do |*args|
|
97
|
+
delivery_info, properties, payload = Hutch::Adapter.decode_message(*args)
|
69
98
|
handle_message(consumer, delivery_info, properties, payload)
|
70
99
|
end
|
71
100
|
end
|
data/spec/hutch/broker_spec.rb
CHANGED
@@ -58,20 +58,35 @@ describe Hutch::Broker do
|
|
58
58
|
before { broker.set_up_amqp_connection }
|
59
59
|
after { broker.disconnect }
|
60
60
|
|
61
|
-
describe '#connection' do
|
61
|
+
describe '#connection', adapter: :bunny do
|
62
62
|
subject { super().connection }
|
63
|
-
it { is_expected.to be_a
|
63
|
+
it { is_expected.to be_a Hutch::Adapters::BunnyAdapter }
|
64
64
|
end
|
65
65
|
|
66
|
-
describe '#
|
66
|
+
describe '#connection', adapter: :march_hare do
|
67
|
+
subject { super().connection }
|
68
|
+
it { is_expected.to be_a Hutch::Adapters::MarchHareAdapter }
|
69
|
+
end
|
70
|
+
|
71
|
+
describe '#channel', adapter: :bunny do
|
67
72
|
subject { super().channel }
|
68
73
|
it { is_expected.to be_a Bunny::Channel }
|
69
74
|
end
|
70
75
|
|
71
|
-
describe '#
|
76
|
+
describe '#channel', adapter: :march_hare do
|
77
|
+
subject { super().channel }
|
78
|
+
it { is_expected.to be_a MarchHare::Channel }
|
79
|
+
end
|
80
|
+
|
81
|
+
describe '#exchange', adapter: :bunny do
|
72
82
|
subject { super().exchange }
|
73
83
|
it { is_expected.to be_a Bunny::Exchange }
|
74
84
|
end
|
85
|
+
|
86
|
+
describe '#exchange', adapter: :march_hare do
|
87
|
+
subject { super().exchange }
|
88
|
+
it { is_expected.to be_a MarchHare::Exchange }
|
89
|
+
end
|
75
90
|
end
|
76
91
|
|
77
92
|
context 'when given invalid details' do
|
@@ -86,11 +101,17 @@ describe Hutch::Broker do
|
|
86
101
|
before { config[:channel_prefetch] = prefetch_value }
|
87
102
|
after { broker.disconnect }
|
88
103
|
|
89
|
-
it "set's channel's prefetch" do
|
104
|
+
it "set's channel's prefetch", adapter: :bunny do
|
90
105
|
expect_any_instance_of(Bunny::Channel).
|
91
106
|
to receive(:prefetch).with(prefetch_value)
|
92
107
|
broker.set_up_amqp_connection
|
93
108
|
end
|
109
|
+
|
110
|
+
it "set's channel's prefetch", adapter: :march_hare do
|
111
|
+
expect_any_instance_of(MarchHare::Channel).
|
112
|
+
to receive(:prefetch=).with(prefetch_value)
|
113
|
+
broker.set_up_amqp_connection
|
114
|
+
end
|
94
115
|
end
|
95
116
|
|
96
117
|
context 'with force_publisher_confirms set' do
|
@@ -98,11 +119,17 @@ describe Hutch::Broker do
|
|
98
119
|
before { config[:force_publisher_confirms] = force_publisher_confirms_value }
|
99
120
|
after { broker.disconnect }
|
100
121
|
|
101
|
-
it 'waits for confirmation' do
|
122
|
+
it 'waits for confirmation', adapter: :bunny do
|
102
123
|
expect_any_instance_of(Bunny::Channel).
|
103
124
|
to receive(:confirm_select)
|
104
125
|
broker.set_up_amqp_connection
|
105
126
|
end
|
127
|
+
|
128
|
+
it 'waits for confirmation', adapter: :march_hare do
|
129
|
+
expect_any_instance_of(MarchHare::Channel).
|
130
|
+
to receive(:confirm_select)
|
131
|
+
broker.set_up_amqp_connection
|
132
|
+
end
|
106
133
|
end
|
107
134
|
end
|
108
135
|
|
@@ -213,7 +240,7 @@ describe Hutch::Broker do
|
|
213
240
|
end
|
214
241
|
end
|
215
242
|
|
216
|
-
describe '#stop' do
|
243
|
+
describe '#stop', adapter: :bunny do
|
217
244
|
let(:thread_1) { double('Thread') }
|
218
245
|
let(:thread_2) { double('Thread') }
|
219
246
|
let(:work_pool) { double('Bunny::ConsumerWorkPool') }
|
@@ -232,6 +259,20 @@ describe Hutch::Broker do
|
|
232
259
|
end
|
233
260
|
end
|
234
261
|
|
262
|
+
describe '#stop', adapter: :march_hare do
|
263
|
+
let(:channel) { double('MarchHare::Channel')}
|
264
|
+
|
265
|
+
before do
|
266
|
+
allow(broker).to receive(:channel).and_return(channel)
|
267
|
+
end
|
268
|
+
|
269
|
+
it 'gracefully stops the channel' do
|
270
|
+
expect(channel).to receive(:close)
|
271
|
+
|
272
|
+
broker.stop
|
273
|
+
end
|
274
|
+
end
|
275
|
+
|
235
276
|
describe '#publish' do
|
236
277
|
context 'with a valid connection' do
|
237
278
|
before { broker.set_up_amqp_connection }
|
@@ -287,11 +328,17 @@ describe Hutch::Broker do
|
|
287
328
|
end
|
288
329
|
|
289
330
|
context 'with force_publisher_confirms not set in the config' do
|
290
|
-
it 'does not wait for confirms on the channel' do
|
331
|
+
it 'does not wait for confirms on the channel', adapter: :bunny do
|
291
332
|
expect_any_instance_of(Bunny::Channel).
|
292
333
|
to_not receive(:wait_for_confirms)
|
293
334
|
broker.publish('test.key', 'message')
|
294
335
|
end
|
336
|
+
|
337
|
+
it 'does not wait for confirms on the channel', adapter: :march_hare do
|
338
|
+
expect_any_instance_of(MarchHare::Channel).
|
339
|
+
to_not receive(:wait_for_confirms)
|
340
|
+
broker.publish('test.key', 'message')
|
341
|
+
end
|
295
342
|
end
|
296
343
|
|
297
344
|
context 'with force_publisher_confirms set in the config' do
|
@@ -301,11 +348,17 @@ describe Hutch::Broker do
|
|
301
348
|
config[:force_publisher_confirms] = force_publisher_confirms_value
|
302
349
|
end
|
303
350
|
|
304
|
-
it 'waits for confirms on the channel' do
|
351
|
+
it 'waits for confirms on the channel', adapter: :bunny do
|
305
352
|
expect_any_instance_of(Bunny::Channel).
|
306
353
|
to receive(:wait_for_confirms)
|
307
354
|
broker.publish('test.key', 'message')
|
308
355
|
end
|
356
|
+
|
357
|
+
it 'waits for confirms on the channel', adapter: :march_hare do
|
358
|
+
expect_any_instance_of(MarchHare::Channel).
|
359
|
+
to receive(:wait_for_confirms)
|
360
|
+
broker.publish('test.key', 'message')
|
361
|
+
end
|
309
362
|
end
|
310
363
|
end
|
311
364
|
|
@@ -322,4 +375,3 @@ describe Hutch::Broker do
|
|
322
375
|
end
|
323
376
|
end
|
324
377
|
end
|
325
|
-
|
data/spec/spec_helper.rb
CHANGED
@@ -16,6 +16,12 @@ require 'logger'
|
|
16
16
|
RSpec.configure do |config|
|
17
17
|
config.before(:all) { Hutch::Config.log_level = Logger::FATAL }
|
18
18
|
config.raise_errors_for_deprecations!
|
19
|
+
|
20
|
+
if defined?(JRUBY_VERSION)
|
21
|
+
config.filter_run_excluding adapter: :bunny
|
22
|
+
else
|
23
|
+
config.filter_run_excluding adapter: :march_hare
|
24
|
+
end
|
19
25
|
end
|
20
26
|
|
21
27
|
# Constants (classes, etc) defined within a block passed to this method
|
@@ -32,4 +38,3 @@ end
|
|
32
38
|
def deep_copy(obj)
|
33
39
|
Marshal.load(Marshal.dump(obj))
|
34
40
|
end
|
35
|
-
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hutch
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.18.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Harry Marr
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -117,6 +117,9 @@ files:
|
|
117
117
|
- examples/producer.rb
|
118
118
|
- hutch.gemspec
|
119
119
|
- lib/hutch.rb
|
120
|
+
- lib/hutch/adapter.rb
|
121
|
+
- lib/hutch/adapters/bunny.rb
|
122
|
+
- lib/hutch/adapters/march_hare.rb
|
120
123
|
- lib/hutch/broker.rb
|
121
124
|
- lib/hutch/cli.rb
|
122
125
|
- lib/hutch/config.rb
|
@@ -167,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
167
170
|
version: '0'
|
168
171
|
requirements: []
|
169
172
|
rubyforge_project:
|
170
|
-
rubygems_version: 2.4.
|
173
|
+
rubygems_version: 2.4.8
|
171
174
|
signing_key:
|
172
175
|
specification_version: 4
|
173
176
|
summary: Easy inter-service communication using RabbitMQ.
|
@@ -185,3 +188,4 @@ test_files:
|
|
185
188
|
- spec/hutch/worker_spec.rb
|
186
189
|
- spec/hutch_spec.rb
|
187
190
|
- spec/spec_helper.rb
|
191
|
+
has_rdoc:
|