hutch 0.12.0 → 0.13.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a85a84008f00348fd3416e1067d5edc68dce0b50
4
- data.tar.gz: 195ad53e080145096107e8c418f40c724918299e
3
+ metadata.gz: c16188d79e67f6645279e39fc3a628d70ebb2468
4
+ data.tar.gz: c82d50ef75cda6ac8482e66a561c9db6175166ec
5
5
  SHA512:
6
- metadata.gz: 1d70d2c0c9ca01d0786840e258b6652c396b220e88b87dbff53e6241aa2e4490babd2a274e385e44b988a5380c129acefc13a8c96caa4e46ec12520c99918e9d
7
- data.tar.gz: 43aa778b97d94fcb778b901c9f0fac74d48c8ae098274811ac068288df497431f8adbb0e514a395c936eed605dffea54e97c375a97be24bdfc3f0761b016dcd1
6
+ metadata.gz: 8d264879570aa9a3b7493ac5fdf9aa9739780073a6b6649cec0d9bced34a1558e677bc2f17c543cd9cdaab493d43e82d68da275668d16d74b42c61af7447990d
7
+ data.tar.gz: 6eb7f683f37389a6263bc8de520dc34084007d1cafe1ba11f6510be37bc02c3f05827dd9cbc1f4552570c8d1f81c7fd972ccc691a65ae09acd9c12f18cd797c0
data/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
- ## 0.12.0 — unreleased
1
+ ## 0.13.0 — Dec 5th, 2014
2
+
3
+ ### HTTP API Can Be Disabled for Consumers
4
+
5
+ HTTP API use can be disabled for consumers using the `:enable_http_api_use` config
6
+ option (defaults to true).
7
+
8
+
9
+
10
+ ## 0.12.0 — Nov 25th, 2014
2
11
 
3
12
  ### Explicit Requires
4
13
 
data/lib/hutch/broker.rb CHANGED
@@ -15,8 +15,14 @@ module Hutch
15
15
  end
16
16
 
17
17
  def connect(options = {})
18
+ @options = options
18
19
  set_up_amqp_connection
19
- set_up_api_connection if options.fetch(:enable_http_api_use, true)
20
+ if http_api_use_enabled?
21
+ logger.info "HTTP API use is enabled"
22
+ set_up_api_connection
23
+ else
24
+ logger.info "HTTP API use is disabled"
25
+ end
20
26
 
21
27
  if block_given?
22
28
  begin
@@ -59,22 +65,27 @@ module Hutch
59
65
  @config[:mq_password] = u.password
60
66
  end
61
67
 
62
- host = @config[:mq_host]
63
- port = @config[:mq_port]
64
- vhost = @config[:mq_vhost]
65
- username = @config[:mq_username]
66
- password = @config[:mq_password]
67
- tls = @config[:mq_tls]
68
- tls_key = @config[:mq_tls_key]
69
- tls_cert = @config[:mq_tls_cert]
70
- protocol = tls ? "amqps://" : "amqp://"
71
- sanitized_uri = "#{protocol}#{username}@#{host}:#{port}/#{vhost.sub(/^\//, '')}"
68
+ host = @config[:mq_host]
69
+ port = @config[:mq_port]
70
+ vhost = if @config[:mq_vhost] && "" != @config[:mq_vhost]
71
+ @config[:mq_vhost]
72
+ else
73
+ Bunny::Session::DEFAULT_VHOST
74
+ end
75
+ username = @config[:mq_username]
76
+ password = @config[:mq_password]
77
+ tls = @config[:mq_tls]
78
+ tls_key = @config[:mq_tls_key]
79
+ tls_cert = @config[:mq_tls_cert]
80
+ connection_timeout = @config[:connection_timeout]
81
+ protocol = tls ? "amqps://" : "amqp://"
82
+ sanitized_uri = "#{protocol}#{username}@#{host}:#{port}/#{vhost.sub(/^\//, '')}"
72
83
  logger.info "connecting to rabbitmq (#{sanitized_uri})"
73
84
  @connection = Bunny.new(host: host, port: port, vhost: vhost,
74
85
  tls: tls, tls_key: tls_key, tls_cert: tls_cert,
75
86
  username: username, password: password,
76
87
  heartbeat: 30, automatically_recover: true,
77
- network_recovery_interval: 1)
88
+ network_recovery_interval: 1, connection_timeout: connection_timeout)
78
89
 
79
90
  with_bunny_connection_handler(sanitized_uri) do
80
91
  @connection.start
@@ -111,6 +122,17 @@ module Hutch
111
122
  end
112
123
  end
113
124
 
125
+ def http_api_use_enabled?
126
+ op = @options.fetch(:enable_http_api_use, true)
127
+ cf = if @config[:enable_http_api_use].nil?
128
+ true
129
+ else
130
+ @config[:enable_http_api_use]
131
+ end
132
+
133
+ op && cf
134
+ end
135
+
114
136
  # Create / get a durable queue and apply namespace if it exists.
115
137
  def queue(name)
116
138
  with_bunny_precondition_handler('queue') do
@@ -136,12 +158,14 @@ module Hutch
136
158
  # existing bindings on the queue that aren't present in the array of
137
159
  # routing keys will be unbound.
138
160
  def bind_queue(queue, routing_keys)
139
- # Find the existing bindings, and unbind any redundant bindings
140
- queue_bindings = bindings.select { |dest, keys| dest == queue.name }
141
- queue_bindings.each do |dest, keys|
142
- keys.reject { |key| routing_keys.include?(key) }.each do |key|
143
- logger.debug "removing redundant binding #{queue.name} <--> #{key}"
144
- queue.unbind(@exchange, routing_key: key)
161
+ if http_api_use_enabled?
162
+ # Find the existing bindings, and unbind any redundant bindings
163
+ queue_bindings = bindings.select { |dest, keys| dest == queue.name }
164
+ queue_bindings.each do |dest, keys|
165
+ keys.reject { |key| routing_keys.include?(key) }.each do |key|
166
+ logger.debug "removing redundant binding #{queue.name} <--> #{key}"
167
+ queue.unbind(@exchange, routing_key: key)
168
+ end
145
169
  end
146
170
  end
147
171
 
@@ -270,7 +294,7 @@ module Hutch
270
294
  yield
271
295
  rescue Bunny::TCPConnectionFailed => ex
272
296
  logger.error "amqp connection error: #{ex.message.downcase}"
273
- raise ConnectionError.new("couldn't connect to rabbitmq at #{uri}")
297
+ raise ConnectionError.new("couldn't connect to rabbitmq at #{uri}. Check your configuration, network connectivity and RabbitMQ logs.")
274
298
  end
275
299
 
276
300
  def work_pool_threads
data/lib/hutch/config.rb CHANGED
@@ -37,7 +37,10 @@ module Hutch
37
37
  publisher_confirms: false,
38
38
  # like `publisher_confirms` above but also
39
39
  # forces waiting for a confirm for every publish
40
- force_publisher_confirms: false
40
+ force_publisher_confirms: false,
41
+ # Heroku needs > 10. MK.
42
+ connection_timeout: 11,
43
+ enable_http_api_use: true
41
44
  }.merge(params)
42
45
  end
43
46
 
data/lib/hutch/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  module Hutch
2
- VERSION = '0.12.0'.freeze
2
+ VERSION = '0.13.0'.freeze
3
3
  end
4
4
 
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.12.0
4
+ version: 0.13.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: 2014-11-25 00:00:00.000000000 Z
11
+ date: 2014-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bunny