hutch 0.20.0 → 0.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/CHANGELOG.md +22 -2
- data/LICENSE +1 -1
- data/README.md +1 -1
- data/hutch.gemspec +2 -2
- data/lib/hutch/broker.rb +1 -1
- data/lib/hutch/cli.rb +7 -4
- data/lib/hutch/exceptions.rb +8 -4
- data/lib/hutch/version.rb +1 -1
- data/lib/hutch/worker.rb +25 -20
- metadata +4 -5
- data/circle.yml +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85403719cdd5fb675886fc2dd6a830a544b3f8ea
|
4
|
+
data.tar.gz: ca485c1fe62a41867f634d46a45798570b3d441f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0ff8d4d207f98acadd27035454a23aa50119076621b01b71fa21d342df02ff67574454f0b26374a60a2b04d941d1b170a6dfd420d12136abb404a17990ab5ea7
|
7
|
+
data.tar.gz: 62fef649721ee040dd1555310a6cd6338da4d00807ab5a6f41cb940e131df919a97e3dc173b2c2a4a9bfff311bce5835f1d37652472229470353c7787af407f7
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,23 @@
|
|
1
|
-
## 0.
|
1
|
+
## 0.21.0 — (unreleased)
|
2
|
+
|
3
|
+
### JRuby Compatibility Restored
|
4
|
+
|
5
|
+
Contributed by Jesper Josefsson.
|
6
|
+
|
7
|
+
### More Reliable Rails app Detection
|
8
|
+
|
9
|
+
Rails application detection now won't produce false positives
|
10
|
+
for applications that include `config/environment.rb`. Instead,
|
11
|
+
`bin/rails` and `script/rails` are used.
|
12
|
+
|
13
|
+
Contributed by @bisusubedi.
|
14
|
+
|
15
|
+
### Refactoring
|
16
|
+
|
17
|
+
Contributed by Jesper Josefsson and Olle Jonsson.
|
18
|
+
|
19
|
+
|
20
|
+
## 0.20.0 — November 16th, 2015
|
2
21
|
|
3
22
|
### Hutch::Exception includes Bunny::Exception
|
4
23
|
|
@@ -50,7 +69,8 @@ GH issue: [#177](https://github.com/gocardless/hutch/pull/177).
|
|
50
69
|
|
51
70
|
`:mq_exchange_options` is a new config option that can be used
|
52
71
|
to provide a hash of exchange attributes (durable, auto-delete).
|
53
|
-
The options will be passed directly to Bunny
|
72
|
+
The options will be passed directly to Bunny (or March Hare, when
|
73
|
+
running on JRuby).
|
54
74
|
|
55
75
|
Contributed by Derek Kastner.
|
56
76
|
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -314,7 +314,7 @@ Known configuration parameters are:
|
|
314
314
|
* `heartbeat`: [RabbitMQ heartbeat timeout](http://rabbitmq.com/heartbeats.html) (default: `30`)
|
315
315
|
* `connection_timeout`: Bunny's socket open timeout (default: `11`)
|
316
316
|
* `read_timeout`: Bunny's socket read timeout (default: `11`)
|
317
|
-
* `
|
317
|
+
* `write_timeout`: Bunny's socket write timeout (default: `11`)
|
318
318
|
* `tracer`: tracer to use to track message processing
|
319
319
|
|
320
320
|
|
data/hutch.gemspec
CHANGED
@@ -3,10 +3,10 @@ require File.expand_path('../lib/hutch/version', __FILE__)
|
|
3
3
|
Gem::Specification.new do |gem|
|
4
4
|
if defined?(JRUBY_VERSION)
|
5
5
|
gem.platform = 'java'
|
6
|
-
gem.add_runtime_dependency 'march_hare', '>= 2.
|
6
|
+
gem.add_runtime_dependency 'march_hare', '>= 2.16.0'
|
7
7
|
else
|
8
8
|
gem.platform = Gem::Platform::RUBY
|
9
|
-
gem.add_runtime_dependency 'bunny', '>= 2.2.
|
9
|
+
gem.add_runtime_dependency 'bunny', '>= 2.2.2'
|
10
10
|
end
|
11
11
|
gem.add_runtime_dependency 'carrot-top', '~> 0.0.7'
|
12
12
|
gem.add_runtime_dependency 'multi_json', '~> 1.11.2'
|
data/lib/hutch/broker.rb
CHANGED
@@ -294,7 +294,7 @@ module Hutch
|
|
294
294
|
params[:automatically_recover] = true
|
295
295
|
params[:network_recovery_interval] = 1
|
296
296
|
|
297
|
-
params[:
|
297
|
+
params[:logger] = @config[:client_logger] if @config[:client_logger]
|
298
298
|
end
|
299
299
|
end
|
300
300
|
|
data/lib/hutch/cli.rb
CHANGED
@@ -42,8 +42,8 @@ module Hutch
|
|
42
42
|
# Need to add '.' to load path for relative requires
|
43
43
|
$LOAD_PATH << '.'
|
44
44
|
require path
|
45
|
-
rescue LoadError
|
46
|
-
logger.fatal "could not load file '#{path}'"
|
45
|
+
rescue LoadError => e
|
46
|
+
logger.fatal "could not load file '#{path}': #{e}"
|
47
47
|
return false
|
48
48
|
ensure
|
49
49
|
# Clean up load path
|
@@ -65,9 +65,12 @@ module Hutch
|
|
65
65
|
def load_rails_app(path)
|
66
66
|
# path should point to the app's top level directory
|
67
67
|
if File.directory?(path)
|
68
|
-
# Smells like a Rails app if it's got a
|
68
|
+
# Smells like a Rails app if it's got a script/rails or bin/rails file
|
69
|
+
is_rails_app = ['script/rails', 'bin/rails'].any? do |file|
|
70
|
+
File.exist?(File.expand_path(File.join(path, file)))
|
71
|
+
end
|
69
72
|
rails_path = File.expand_path(File.join(path, 'config/environment.rb'))
|
70
|
-
if File.
|
73
|
+
if is_rails_app && File.exist?(rails_path)
|
71
74
|
logger.info "found rails project (#{path}), booting app"
|
72
75
|
ENV['RACK_ENV'] ||= ENV['RAILS_ENV'] || 'development'
|
73
76
|
require rails_path
|
data/lib/hutch/exceptions.rb
CHANGED
@@ -1,8 +1,12 @@
|
|
1
|
-
require "bunny/exceptions"
|
2
|
-
|
3
1
|
module Hutch
|
4
|
-
|
5
|
-
|
2
|
+
if defined?(JRUBY_VERSION)
|
3
|
+
require 'march_hare/exceptions'
|
4
|
+
class Exception < MarchHare::Exception; end
|
5
|
+
else
|
6
|
+
require "bunny/exceptions"
|
7
|
+
# Bunny::Exception inherits from StandardError
|
8
|
+
class Exception < Bunny::Exception; end
|
9
|
+
end
|
6
10
|
class ConnectionError < Exception; end
|
7
11
|
class AuthenticationError < Exception; end
|
8
12
|
class WorkerSetupError < Exception; end
|
data/lib/hutch/version.rb
CHANGED
data/lib/hutch/worker.rb
CHANGED
@@ -8,6 +8,8 @@ module Hutch
|
|
8
8
|
class Worker
|
9
9
|
include Logging
|
10
10
|
|
11
|
+
SHUTDOWN_SIGNALS = %w(QUIT TERM INT)
|
12
|
+
|
11
13
|
def initialize(broker, consumers)
|
12
14
|
@broker = broker
|
13
15
|
self.consumers = consumers
|
@@ -42,7 +44,7 @@ module Hutch
|
|
42
44
|
# gracefully. Forceful shutdowns are very bad!
|
43
45
|
def register_signal_handlers
|
44
46
|
Thread.main[:signal_queue] = []
|
45
|
-
|
47
|
+
supported_shutdown_signals.each do |sig|
|
46
48
|
# This needs to be reentrant, so we queue up signals to be handled
|
47
49
|
# in the run loop, rather than acting on signals here
|
48
50
|
trap(sig) do
|
@@ -103,25 +105,22 @@ module Hutch
|
|
103
105
|
# Called internally when a new messages comes in from RabbitMQ. Responsible
|
104
106
|
# for wrapping up the message and passing it to the consumer.
|
105
107
|
def handle_message(consumer, delivery_info, properties, payload)
|
106
|
-
|
107
|
-
|
108
|
-
serializer
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
acknowledge_error(delivery_info, properties, broker, ex)
|
123
|
-
handle_error(properties.message_id, payload, consumer, ex)
|
124
|
-
end
|
108
|
+
serializer = consumer.get_serializer || Hutch::Config[:serializer]
|
109
|
+
logger.info {
|
110
|
+
spec = serializer.binary? ? "#{payload.bytesize} bytes" : "#{payload}"
|
111
|
+
"message(#{properties.message_id || '-'}): " +
|
112
|
+
"routing key: #{delivery_info.routing_key}, " +
|
113
|
+
"consumer: #{consumer}, " +
|
114
|
+
"payload: #{spec}"
|
115
|
+
}
|
116
|
+
|
117
|
+
message = Message.new(delivery_info, properties, payload, serializer)
|
118
|
+
consumer_instance = consumer.new.tap { |c| c.broker, c.delivery_info = @broker, delivery_info }
|
119
|
+
with_tracing(consumer_instance).handle(message)
|
120
|
+
@broker.ack(delivery_info.delivery_tag)
|
121
|
+
rescue => ex
|
122
|
+
acknowledge_error(delivery_info, properties, @broker, ex)
|
123
|
+
handle_error(properties.message_id, payload, consumer, ex)
|
125
124
|
end
|
126
125
|
|
127
126
|
def with_tracing(klass)
|
@@ -152,5 +151,11 @@ module Hutch
|
|
152
151
|
def error_acknowledgements
|
153
152
|
Hutch::Config[:error_acknowledgements]
|
154
153
|
end
|
154
|
+
|
155
|
+
private
|
156
|
+
|
157
|
+
def supported_shutdown_signals
|
158
|
+
SHUTDOWN_SIGNALS.keep_if { |s| Signal.list.keys.include? s }.map(&:to_sym)
|
159
|
+
end
|
155
160
|
end
|
156
161
|
end
|
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.21.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:
|
11
|
+
date: 2016-02-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 2.2.
|
19
|
+
version: 2.2.2
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 2.2.
|
26
|
+
version: 2.2.2
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: carrot-top
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,7 +112,6 @@ files:
|
|
112
112
|
- README.md
|
113
113
|
- Rakefile
|
114
114
|
- bin/hutch
|
115
|
-
- circle.yml
|
116
115
|
- examples/consumer.rb
|
117
116
|
- examples/producer.rb
|
118
117
|
- hutch.gemspec
|
data/circle.yml
DELETED