routemaster-drain 3.0.3 → 3.1.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 +6 -0
- data/lib/routemaster/api_client.rb +13 -12
- data/lib/routemaster/drain.rb +1 -1
- data/spec/routemaster/api_client_spec.rb +55 -14
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eb1cccd206b6825ce76f748a269bfbc261ff4328
|
4
|
+
data.tar.gz: a05de95ccc0c4643015f69aeeb7bbf02c4905d4f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb053523998b5303d8c47d52963c27fac7a87181f28a33ed0a84e8739103c8031bbb3955567440a229eb0691b8878da257c585d5bcd05ac1ae5d1ba5a6028c39
|
7
|
+
data.tar.gz: db39fcb620c32576258a6f94ebc70eaed859cd3b5ea61f4ac899fec68df30ed7f9170cb2535b035a2c40de6425a93cd2b87b99f0e3096e6381fafacc3a3be0cb
|
data/CHANGELOG.md
CHANGED
@@ -34,17 +34,14 @@ module Routemaster
|
|
34
34
|
# all the time to fetch the root resource before doing anything else.
|
35
35
|
@@root_resources = {}
|
36
36
|
|
37
|
-
def initialize(
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@
|
44
|
-
@
|
45
|
-
@default_response_class = response_class
|
46
|
-
@metrics_client = metrics_client
|
47
|
-
@source_peer = source_peer
|
37
|
+
def initialize(options = {})
|
38
|
+
@listener = options.fetch :listener, nil
|
39
|
+
@middlewares = options.fetch :middlewares, []
|
40
|
+
@default_response_class = options.fetch :response_class, nil
|
41
|
+
@metrics_client = options.fetch :metrics_client, nil
|
42
|
+
@source_peer = options.fetch :source_peer, nil
|
43
|
+
@retry_attempts = options.fetch :retry_attempts, 2
|
44
|
+
@retry_methods = options.fetch :retry_methods, Faraday::Request::Retry::IDEMPOTENT_METHODS
|
48
45
|
|
49
46
|
connection # warm up connection so Faraday does all it's magical file loading in the main thread
|
50
47
|
end
|
@@ -123,7 +120,11 @@ module Routemaster
|
|
123
120
|
def connection
|
124
121
|
@connection ||= Faraday.new do |f|
|
125
122
|
f.request :json
|
126
|
-
f.request :retry,
|
123
|
+
f.request :retry,
|
124
|
+
max: @retry_attempts,
|
125
|
+
interval: 100e-3,
|
126
|
+
backoff_factor: 2,
|
127
|
+
methods: @retry_methods
|
127
128
|
f.response :mashify
|
128
129
|
f.response :json, content_type: /\bjson/
|
129
130
|
f.use Routemaster::Middleware::ResponseCaching, listener: @listener
|
data/lib/routemaster/drain.rb
CHANGED
@@ -159,24 +159,65 @@ describe Routemaster::APIClient do
|
|
159
159
|
end
|
160
160
|
|
161
161
|
describe '#patch' do
|
162
|
-
|
162
|
+
let(:body) { { 'one' => 1, 'two' => 2 }.to_json }
|
163
|
+
subject { fetcher.patch(url, body: body, headers: headers) }
|
163
164
|
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
165
|
+
context 'when request succeeds' do
|
166
|
+
before do
|
167
|
+
@patch_req = stub_request(:patch, /example\.com/).to_return(
|
168
|
+
status: 200,
|
169
|
+
body: { id: 132, type: 'widget' }.to_json,
|
170
|
+
headers: {
|
171
|
+
'content-type' => 'application/json;v=1'
|
172
|
+
}
|
173
|
+
)
|
174
|
+
end
|
173
175
|
|
174
|
-
|
175
|
-
|
176
|
-
|
176
|
+
it 'PATCH from the URL' do
|
177
|
+
subject
|
178
|
+
expect(@patch_req).to have_been_requested
|
179
|
+
end
|
180
|
+
|
181
|
+
it_behaves_like 'a wrappable response'
|
177
182
|
end
|
178
183
|
|
179
|
-
|
184
|
+
context 'when request times out' do
|
185
|
+
subject do
|
186
|
+
begin
|
187
|
+
fetcher.patch(url, body: body, headers: headers)
|
188
|
+
rescue Faraday::TimeoutError
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
before do
|
193
|
+
stub_request(:patch, url).to_timeout
|
194
|
+
end
|
195
|
+
|
196
|
+
it 'tries the PATCH request only once' do
|
197
|
+
subject
|
198
|
+
assert_requested(:patch, url, body: body, times: 1)
|
199
|
+
end
|
200
|
+
|
201
|
+
context 'when PATCH is specified as a method to retry' do
|
202
|
+
let(:retry_methods) { [:patch] }
|
203
|
+
let(:fetcher) { described_class.new(retry_methods: retry_methods) }
|
204
|
+
|
205
|
+
it 'tries the PATCH request 3 times' do
|
206
|
+
subject
|
207
|
+
assert_requested(:patch, url, body: body, times: 3)
|
208
|
+
end
|
209
|
+
|
210
|
+
context 'when retry attempt count is specified' do
|
211
|
+
let(:retry_attempts) { 4 }
|
212
|
+
let(:fetcher) { described_class.new(retry_methods: retry_methods, retry_attempts: retry_attempts) }
|
213
|
+
|
214
|
+
it "tries the PATCH request '1 + retry-count' times" do
|
215
|
+
subject
|
216
|
+
assert_requested(:patch, url, body: body, times: 1 + retry_attempts)
|
217
|
+
end
|
218
|
+
end
|
219
|
+
end
|
220
|
+
end
|
180
221
|
end
|
181
222
|
|
182
223
|
describe '#delete' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: routemaster-drain
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0
|
4
|
+
version: 3.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Letessier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-11-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
270
270
|
version: '0'
|
271
271
|
requirements: []
|
272
272
|
rubyforge_project:
|
273
|
-
rubygems_version: 2.6.
|
273
|
+
rubygems_version: 2.6.11
|
274
274
|
signing_key:
|
275
275
|
specification_version: 4
|
276
276
|
summary: Event receiver for the Routemaster bus
|
@@ -317,4 +317,3 @@ test_files:
|
|
317
317
|
- spec/support/uses_dotenv.rb
|
318
318
|
- spec/support/uses_redis.rb
|
319
319
|
- spec/support/uses_webmock.rb
|
320
|
-
has_rdoc:
|