pebbles-river 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/pebbles/river/river.rb +8 -5
- data/lib/pebbles/river/version.rb +1 -1
- data/spec/lib/river_spec.rb +24 -2
- data/spec/lib/worker_spec.rb +1 -1
- metadata +2 -2
data/lib/pebbles/river/river.rb
CHANGED
@@ -108,18 +108,21 @@ module Pebbles
|
|
108
108
|
retry
|
109
109
|
end
|
110
110
|
end
|
111
|
-
rescue Timeout::Error =>
|
112
|
-
last_exception
|
113
|
-
|
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 =
|
123
|
+
MAX_RETRY_TIMEOUT = 30
|
121
124
|
|
122
|
-
MAX_BACKOFF_SECONDS =
|
125
|
+
MAX_BACKOFF_SECONDS = 10
|
123
126
|
|
124
127
|
EXCHANGE_OPTIONS = {type: :topic, durable: :true}.freeze
|
125
128
|
|
data/spec/lib/river_spec.rb
CHANGED
@@ -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.
|
162
|
-
e.
|
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
|
data/spec/lib/worker_spec.rb
CHANGED
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.
|
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-
|
13
|
+
date: 2014-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: pebblebed
|