hutch 0.20.0 → 0.21.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9d93317d6750bca3658656b8b919dbdf9b277cf5
4
- data.tar.gz: ce7f0b6bad0ea3764e13e634f764285f75927bdf
3
+ metadata.gz: 85403719cdd5fb675886fc2dd6a830a544b3f8ea
4
+ data.tar.gz: ca485c1fe62a41867f634d46a45798570b3d441f
5
5
  SHA512:
6
- metadata.gz: 6f39fa63c8d77ea71444ab25cfd599bfc89ad9e8c222323f69b322e66a179347fec7c1afb100b5575af08d1a6522af1d2e4adeef827c40f825313e76640482d9
7
- data.tar.gz: d3c94ca6c2720fa3fd4197f408dc8832f9f904941dbd1cc556e13efae7b0768b2ab1be0c58159676cce4b78c0c5ccac9e15f8a55c780d6d251b0b42f54a55161
6
+ metadata.gz: 0ff8d4d207f98acadd27035454a23aa50119076621b01b71fa21d342df02ff67574454f0b26374a60a2b04d941d1b170a6dfd420d12136abb404a17990ab5ea7
7
+ data.tar.gz: 62fef649721ee040dd1555310a6cd6338da4d00807ab5a6f41cb940e131df919a97e3dc173b2c2a4a9bfff311bce5835f1d37652472229470353c7787af407f7
@@ -1,11 +1,17 @@
1
1
  language: ruby
2
+ cache: bundler
2
3
  rvm:
4
+ - "2.3.0"
3
5
  - "2.2"
4
6
  - "2.1"
5
7
  - "2.0"
6
8
  - "jruby-9.0.0.0"
9
+
10
+ sudo: false
11
+
7
12
  services:
8
13
  - rabbitmq
14
+
9
15
  matrix:
10
16
  allow_failures:
11
17
  - rvm: jruby-9.0.0.0
@@ -1,4 +1,23 @@
1
- ## 0.20.0 — (unreleased)
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
@@ -1,4 +1,4 @@
1
- Copyright (c) 2013-2014 GoCardless
1
+ Copyright (c) 2013-2016 GoCardless
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person
4
4
  obtaining a copy of this software and associated documentation
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
- * `write_timemout`: Bunny's socket write timeout (default: `11`)
317
+ * `write_timeout`: Bunny's socket write timeout (default: `11`)
318
318
  * `tracer`: tracer to use to track message processing
319
319
 
320
320
 
@@ -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.11.0'
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.1'
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'
@@ -294,7 +294,7 @@ module Hutch
294
294
  params[:automatically_recover] = true
295
295
  params[:network_recovery_interval] = 1
296
296
 
297
- params[:client_logger] = @config[:client_logger] if @config[:client_logger]
297
+ params[:logger] = @config[:client_logger] if @config[:client_logger]
298
298
  end
299
299
  end
300
300
 
@@ -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 config/environment.rb file
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.exists?(rails_path)
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
@@ -1,8 +1,12 @@
1
- require "bunny/exceptions"
2
-
3
1
  module Hutch
4
- # Bunny::Exception inherits from StandardError
5
- class Exception < Bunny::Exception; end
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
@@ -1,4 +1,4 @@
1
1
  module Hutch
2
- VERSION = '0.20.0'.freeze
2
+ VERSION = '0.21.0'.freeze
3
3
  end
4
4
 
@@ -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
- %w(QUIT TERM INT).keep_if { |s| Signal.list.keys.include? s }.map(&:to_sym).each do |sig|
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
- broker = @broker
107
- begin
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 StandardError => ex
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.20.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: 2015-11-15 00:00:00.000000000 Z
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.1
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.1
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
@@ -1,3 +0,0 @@
1
- machine:
2
- services:
3
- - rabbitmq-server