pebbles-river 0.2.0 → 0.2.1

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.
@@ -108,18 +108,21 @@ module Pebbles
108
108
  retry
109
109
  end
110
110
  end
111
- rescue Timeout::Error => timeout
112
- last_exception ||= timeout
113
- raise exception_klass.new(last_exception.message, last_exception)
111
+ rescue Timeout::Error => timeout_exception
112
+ if last_exception
113
+ raise exception_klass.new(last_exception.message, last_exception)
114
+ else
115
+ raise exception_klass.new("Timeout", timeout_exception)
116
+ end
114
117
  end
115
118
 
116
119
  def backoff(iteration)
117
120
  sleep([(1.0 / 2.0 * (2.0 ** [30, iteration].min - 1.0)).ceil, MAX_BACKOFF_SECONDS].min)
118
121
  end
119
122
 
120
- MAX_RETRY_TIMEOUT = 10
123
+ MAX_RETRY_TIMEOUT = 30
121
124
 
122
- MAX_BACKOFF_SECONDS = MAX_RETRY_TIMEOUT
125
+ MAX_BACKOFF_SECONDS = 10
123
126
 
124
127
  EXCHANGE_OPTIONS = {type: :topic, durable: :true}.freeze
125
128
 
@@ -1,5 +1,5 @@
1
1
  module Pebbles
2
2
  module River
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -158,8 +158,8 @@ describe Pebbles::River::River do
158
158
  expect(subject).to receive(:disconnect).at_least(11).times
159
159
 
160
160
  expect(-> { subject.publish({event: 'explode', uid: 'thing:rspec$1'})}).to raise_error do |e|
161
- e.should be Pebbles::River::SendFailure
162
- e.exception.should be exception_class
161
+ expect(e).to be_instance_of Pebbles::River::SendFailure
162
+ expect(e.connection_exception.class).to eq exception_class
163
163
  end
164
164
 
165
165
  expect(sleeps[0, 9]).to eq [1, 2, 4, 8, 10, 10, 10, 10, 10]
@@ -167,6 +167,28 @@ describe Pebbles::River::River do
167
167
  end
168
168
  end
169
169
 
170
+ context 'on connection timeout' do
171
+ it "gives up with SendFailure" do
172
+ exchange = double('exchange')
173
+ exchange.stub(:publish) { }
174
+
175
+ subject.stub(:exchange) { exchange }
176
+
177
+ Timeout.stub(:timeout) { |&block|
178
+ raise Timeout::Error, "execution expired"
179
+ }
180
+ expect(Timeout).to receive(:timeout).exactly(1).times
181
+
182
+ expect(-> {
183
+ subject.publish({event: 'explode', uid: 'thing:rspec$1'})
184
+ }).to raise_error do |e|
185
+ expect(e).to be_instance_of Pebbles::River::SendFailure
186
+ expect(e.message).to eq 'Timeout'
187
+ expect(e.connection_exception.class).to eq Timeout::Error
188
+ end
189
+ end
190
+ end
191
+
170
192
  end
171
193
 
172
194
  it "subscribes" do
@@ -229,7 +229,7 @@ describe Worker do
229
229
 
230
230
  let :handler do
231
231
  handler = double('handler')
232
- handler.stub(:call).and_return {
232
+ allow(handler).to receive(:call) {
233
233
  raise exception
234
234
  }
235
235
  handler
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pebbles-river
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2014-10-23 00:00:00.000000000 Z
13
+ date: 2014-11-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: pebblebed