hutch 0.5.0 → 0.5.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +1 -1
- data/lib/hutch/broker.rb +16 -7
- data/lib/hutch/exceptions.rb +1 -0
- data/lib/hutch/version.rb +1 -1
- data/spec/hutch/broker_spec.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 49a9fedccdbf581b5874f8a546ce20545d683b96
|
4
|
+
data.tar.gz: 1783f96443d36488ed329271e5f382123ed79a98
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d59463f950dd59b7a5cb575b6eeb47d97400fcea4626d168902b7d5c442f791d907ece465a2841c68c6c09a85b253da33eae08d3b6228cf1b19315680bf972b2
|
7
|
+
data.tar.gz: 3f7d8abae79d3227d656c427bc3d6201060545a8fab2523d89c1048011b52506481f8041e0ed7923e2c32a18d1db78ca2e9ff36d5eee07c8edbccb6f4f70c92b
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
data/lib/hutch/broker.rb
CHANGED
@@ -151,14 +151,23 @@ module Hutch
|
|
151
151
|
def publish(routing_key, message)
|
152
152
|
payload = JSON.dump(message)
|
153
153
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
154
|
+
unless @connection
|
155
|
+
msg = "Unable to publish - no connection to broker. " +
|
156
|
+
"Message: #{message.inspect}, Routing key: #{routing_key}."
|
157
|
+
logger.error(msg)
|
158
|
+
raise PublishError, msg
|
159
|
+
end
|
160
|
+
|
161
|
+
unless @connection.open?
|
162
|
+
msg = "Unable to publish - connection is closed. " +
|
163
|
+
"Message: #{message.inspect}, Routing key: #{routing_key}."
|
164
|
+
logger.error(msg)
|
165
|
+
raise PublishError, msg
|
161
166
|
end
|
167
|
+
|
168
|
+
logger.info("publishing message '#{message.inspect}' to #{routing_key}")
|
169
|
+
@exchange.publish(payload, routing_key: routing_key, persistent: true,
|
170
|
+
timestamp: Time.now.to_i, message_id: generate_id)
|
162
171
|
end
|
163
172
|
|
164
173
|
private
|
data/lib/hutch/exceptions.rb
CHANGED
data/lib/hutch/version.rb
CHANGED
data/spec/hutch/broker_spec.rb
CHANGED
@@ -147,9 +147,14 @@ describe Hutch::Broker do
|
|
147
147
|
end
|
148
148
|
|
149
149
|
context 'without a valid connection' do
|
150
|
+
it 'raises an exception' do
|
151
|
+
expect { broker.publish('test.key', 'message') }.
|
152
|
+
to raise_exception(Hutch::PublishError)
|
153
|
+
end
|
154
|
+
|
150
155
|
it 'logs an error' do
|
151
156
|
broker.logger.should_receive(:error)
|
152
|
-
broker.publish('test.key', 'message')
|
157
|
+
broker.publish('test.key', 'message') rescue nil
|
153
158
|
end
|
154
159
|
end
|
155
160
|
end
|