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 +4 -4
- data/CHANGELOG.md +10 -1
- data/lib/hutch/broker.rb +43 -19
- data/lib/hutch/config.rb +4 -1
- data/lib/hutch/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c16188d79e67f6645279e39fc3a628d70ebb2468
|
4
|
+
data.tar.gz: c82d50ef75cda6ac8482e66a561c9db6175166ec
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8d264879570aa9a3b7493ac5fdf9aa9739780073a6b6649cec0d9bced34a1558e677bc2f17c543cd9cdaab493d43e82d68da275668d16d74b42c61af7447990d
|
7
|
+
data.tar.gz: 6eb7f683f37389a6263bc8de520dc34084007d1cafe1ba11f6510be37bc02c3f05827dd9cbc1f4552570c8d1f81c7fd972ccc691a65ae09acd9c12f18cd797c0
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,13 @@
|
|
1
|
-
## 0.
|
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
|
-
|
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
|
63
|
-
port
|
64
|
-
vhost
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
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
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
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
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.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
|
+
date: 2014-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bunny
|