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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9ad4ea66e507cf8c01b3e402c933223e0c525503
4
- data.tar.gz: 736c571f2a6cc790ab2b3dda796a1c29b624ec74
3
+ metadata.gz: 49a9fedccdbf581b5874f8a546ce20545d683b96
4
+ data.tar.gz: 1783f96443d36488ed329271e5f382123ed79a98
5
5
  SHA512:
6
- metadata.gz: d16e7ef03f63fdedf9501bee91dd49e6b5edb03db74e1027d7a0fa1ed140994dd9e545f757484f86441d078271523df98d3d9d9d83156ad33329ca761cfbaae9
7
- data.tar.gz: 719bd84eced5c8876a2dbc43b785db900bc7300a091ffb479a6949fb0797ef66eb354a273b438f92ef3932eba07a1e1703dc8c2abed31cea7fd4bbd52f109a83
6
+ metadata.gz: d59463f950dd59b7a5cb575b6eeb47d97400fcea4626d168902b7d5c442f791d907ece465a2841c68c6c09a85b253da33eae08d3b6228cf1b19315680bf972b2
7
+ data.tar.gz: 3f7d8abae79d3227d656c427bc3d6201060545a8fab2523d89c1048011b52506481f8041e0ed7923e2c32a18d1db78ca2e9ff36d5eee07c8edbccb6f4f70c92b
@@ -1,3 +1,7 @@
1
+ ## 0.5.1 - October 17, 2013
2
+
3
+ - Raise an exception when publishing fails
4
+
1
5
  ## 0.5.0 - October 17, 2013
2
6
 
3
7
  - Support for the `--mq-tls-key` and `--mq-tls-cert` configuration options.
data/README.md CHANGED
@@ -29,7 +29,7 @@ gem install hutch
29
29
  To use in a project managed with Bundler:
30
30
 
31
31
  ``` ruby
32
- gem "hutch", "~> 0.5.0"
32
+ gem "hutch", "~> 0.5.1"
33
33
  ```
34
34
 
35
35
  ## Overview
@@ -151,14 +151,23 @@ module Hutch
151
151
  def publish(routing_key, message)
152
152
  payload = JSON.dump(message)
153
153
 
154
- if @connection && @connection.open?
155
- logger.info "publishing message '#{message.inspect}' to #{routing_key}"
156
- @exchange.publish(payload, routing_key: routing_key, persistent: true,
157
- timestamp: Time.now.to_i, message_id: generate_id)
158
- else
159
- logger.error "Unable to publish : routing key: #{routing_key}, " +
160
- "message: #{message}"
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
@@ -2,4 +2,5 @@ module Hutch
2
2
  class ConnectionError < StandardError; end
3
3
  class AuthenticationError < StandardError; end
4
4
  class WorkerSetupError < StandardError; end
5
+ class PublishError < StandardError; end
5
6
  end
@@ -1,4 +1,4 @@
1
1
  module Hutch
2
- VERSION = '0.5.0'.freeze
2
+ VERSION = '0.5.1'.freeze
3
3
  end
4
4
 
@@ -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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hutch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Harry Marr