routemaster-drain 3.6.4 → 3.6.8

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: 8751ba11d3ecc6376887aca2600adf850839d0ab
4
- data.tar.gz: 3bcbd8c7cdeefdbe07deb264f196a987e7adeda1
3
+ metadata.gz: 431caa4e0158fa1ac795d6feeaa81b96c8e2fe4e
4
+ data.tar.gz: cceb454d55e593655e39131e7f127a7592101368
5
5
  SHA512:
6
- metadata.gz: d30f96275f9ed9785088da2e7d231e7a9f79073bca0f427f796e7a8cc0c42905bd5e1e1d4ef6e97a00f9f665d9433e59d2ee7e04c7e3577a693fb13c4a994cde
7
- data.tar.gz: e82794bf28ddfc30c60a489020a3d14f652bbbc6e6c476015863cd3a067a6282e9e541dee123e39b159d72296e1d4642a3ef53a74f9cded123d5461676eb9eb0
6
+ metadata.gz: f6b4be9f06e085159e29bf2b53bbf171acb04fece4f740482cb28915545788ef77bd94290d85e024fac0b96d1183c5e54e95a0a27ba6496725ea06e119d6c127
7
+ data.tar.gz: 677d45ad6541d7301132e90f2e9516131d2c0559ddda86c61b9c2c4270a405202974f26096030fe082019331e3ce786767d64aa6f7d13d5a34b9a30745e8c2dd
data/.circleci/config.yml CHANGED
@@ -4,340 +4,24 @@
4
4
  version: 2
5
5
  jobs:
6
6
 
7
- build_2.2.7_rails_3:
7
+ build_2.5_rails_5:
8
8
  docker:
9
- - image: deliveroo/multiruby
9
+ - image: circleci/ruby:2.4.1
10
10
  - image: redis:3-alpine
11
11
  steps:
12
12
  - checkout
13
13
 
14
14
  - run:
15
- name: Select build variant (Ruby 2.2.7, rails_3)
15
+ name: Install bundler
16
16
  command: |
17
- rbenv local 2.2.7 ;
18
- gem install bundler ;
19
- bundle config --local gemfile $PWD/gemfiles/rails_3.gemfile
20
-
21
- - restore_cache:
22
- keys:
23
- - v2-bundle-2.2.7-rails_3-{{ .Branch }}
24
- - v2-bundle-2.2.7-rails_3
25
- - v2-bundle-2.2.7
26
-
27
- - run:
28
- name: Install dependencies
29
- command: |
30
- bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
31
-
32
- - run:
33
- name: Run test suite
34
- command: |
35
- unset RACK_ENV &&
36
- unset RAILS_ENV &&
37
- bundle exec rspec
38
-
39
- - save_cache:
40
- key: v2-bundle-2.2.7-rails_3-{{ .Branch }}
41
- paths:
42
- - ~/project/vendor/bundle
43
- - save_cache:
44
- key: v2-bundle-2.2.7-rails_3
45
- paths:
46
- - ~/project/vendor/bundle
47
- - save_cache:
48
- key: v2-bundle-2.2.7
49
- paths:
50
- - ~/project/vendor/bundle
51
-
52
- build_2.3.4_rails_3:
53
- docker:
54
- - image: deliveroo/multiruby
55
- - image: redis:3-alpine
56
- steps:
57
- - checkout
58
-
59
- - run:
60
- name: Select build variant (Ruby 2.3.4, rails_3)
61
- command: |
62
- rbenv local 2.3.4 ;
63
- gem install bundler ;
64
- bundle config --local gemfile $PWD/gemfiles/rails_3.gemfile
65
-
66
- - restore_cache:
67
- keys:
68
- - v2-bundle-2.3.4-rails_3-{{ .Branch }}
69
- - v2-bundle-2.3.4-rails_3
70
- - v2-bundle-2.3.4
71
-
72
- - run:
73
- name: Install dependencies
74
- command: |
75
- bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
76
-
77
- - run:
78
- name: Run test suite
79
- command: |
80
- unset RACK_ENV &&
81
- unset RAILS_ENV &&
82
- bundle exec rspec
83
-
84
- - save_cache:
85
- key: v2-bundle-2.3.4-rails_3-{{ .Branch }}
86
- paths:
87
- - ~/project/vendor/bundle
88
- - save_cache:
89
- key: v2-bundle-2.3.4-rails_3
90
- paths:
91
- - ~/project/vendor/bundle
92
- - save_cache:
93
- key: v2-bundle-2.3.4
94
- paths:
95
- - ~/project/vendor/bundle
96
-
97
- build_2.2.7_rails_4:
98
- docker:
99
- - image: deliveroo/multiruby
100
- - image: redis:3-alpine
101
- steps:
102
- - checkout
103
-
104
- - run:
105
- name: Select build variant (Ruby 2.2.7, rails_4)
106
- command: |
107
- rbenv local 2.2.7 ;
108
- gem install bundler ;
109
- bundle config --local gemfile $PWD/gemfiles/rails_4.gemfile
110
-
111
- - restore_cache:
112
- keys:
113
- - v2-bundle-2.2.7-rails_4-{{ .Branch }}
114
- - v2-bundle-2.2.7-rails_4
115
- - v2-bundle-2.2.7
116
-
117
- - run:
118
- name: Install dependencies
119
- command: |
120
- bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
121
-
122
- - run:
123
- name: Run test suite
124
- command: |
125
- unset RACK_ENV &&
126
- unset RAILS_ENV &&
127
- bundle exec rspec
128
-
129
- - save_cache:
130
- key: v2-bundle-2.2.7-rails_4-{{ .Branch }}
131
- paths:
132
- - ~/project/vendor/bundle
133
- - save_cache:
134
- key: v2-bundle-2.2.7-rails_4
135
- paths:
136
- - ~/project/vendor/bundle
137
- - save_cache:
138
- key: v2-bundle-2.2.7
139
- paths:
140
- - ~/project/vendor/bundle
141
-
142
- build_2.3.4_rails_4:
143
- docker:
144
- - image: deliveroo/multiruby
145
- - image: redis:3-alpine
146
- steps:
147
- - checkout
148
-
149
- - run:
150
- name: Select build variant (Ruby 2.3.4, rails_4)
151
- command: |
152
- rbenv local 2.3.4 ;
153
- gem install bundler ;
154
- bundle config --local gemfile $PWD/gemfiles/rails_4.gemfile
155
-
156
- - restore_cache:
157
- keys:
158
- - v2-bundle-2.3.4-rails_4-{{ .Branch }}
159
- - v2-bundle-2.3.4-rails_4
160
- - v2-bundle-2.3.4
161
-
162
- - run:
163
- name: Install dependencies
164
- command: |
165
- bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
166
-
167
- - run:
168
- name: Run test suite
169
- command: |
170
- unset RACK_ENV &&
171
- unset RAILS_ENV &&
172
- bundle exec rspec
173
-
174
- - save_cache:
175
- key: v2-bundle-2.3.4-rails_4-{{ .Branch }}
176
- paths:
177
- - ~/project/vendor/bundle
178
- - save_cache:
179
- key: v2-bundle-2.3.4-rails_4
180
- paths:
181
- - ~/project/vendor/bundle
182
- - save_cache:
183
- key: v2-bundle-2.3.4
184
- paths:
185
- - ~/project/vendor/bundle
186
-
187
- build_2.4.1_rails_4:
188
- docker:
189
- - image: deliveroo/multiruby
190
- - image: redis:3-alpine
191
- steps:
192
- - checkout
193
-
194
- - run:
195
- name: Select build variant (Ruby 2.4.1, rails_4)
196
- command: |
197
- rbenv local 2.4.1 ;
198
- gem install bundler ;
199
- bundle config --local gemfile $PWD/gemfiles/rails_4.gemfile
200
-
201
- - restore_cache:
202
- keys:
203
- - v2-bundle-2.4.1-rails_4-{{ .Branch }}
204
- - v2-bundle-2.4.1-rails_4
205
- - v2-bundle-2.4.1
206
-
207
- - run:
208
- name: Install dependencies
209
- command: |
210
- bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
211
-
212
- - run:
213
- name: Run test suite
214
- command: |
215
- unset RACK_ENV &&
216
- unset RAILS_ENV &&
217
- bundle exec rspec
218
-
219
- - save_cache:
220
- key: v2-bundle-2.4.1-rails_4-{{ .Branch }}
221
- paths:
222
- - ~/project/vendor/bundle
223
- - save_cache:
224
- key: v2-bundle-2.4.1-rails_4
225
- paths:
226
- - ~/project/vendor/bundle
227
- - save_cache:
228
- key: v2-bundle-2.4.1
229
- paths:
230
- - ~/project/vendor/bundle
231
-
232
- build_2.2.7_rails_5:
233
- docker:
234
- - image: deliveroo/multiruby
235
- - image: redis:3-alpine
236
- steps:
237
- - checkout
238
-
239
- - run:
240
- name: Select build variant (Ruby 2.2.7, rails_5)
241
- command: |
242
- rbenv local 2.2.7 ;
243
- gem install bundler ;
244
- bundle config --local gemfile $PWD/gemfiles/rails_5.gemfile
245
-
246
- - restore_cache:
247
- keys:
248
- - v2-bundle-2.2.7-rails_5-{{ .Branch }}
249
- - v2-bundle-2.2.7-rails_5
250
- - v2-bundle-2.2.7
251
-
252
- - run:
253
- name: Install dependencies
254
- command: |
255
- bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
256
-
257
- - run:
258
- name: Run test suite
259
- command: |
260
- unset RACK_ENV &&
261
- unset RAILS_ENV &&
262
- bundle exec rspec
263
-
264
- - save_cache:
265
- key: v2-bundle-2.2.7-rails_5-{{ .Branch }}
266
- paths:
267
- - ~/project/vendor/bundle
268
- - save_cache:
269
- key: v2-bundle-2.2.7-rails_5
270
- paths:
271
- - ~/project/vendor/bundle
272
- - save_cache:
273
- key: v2-bundle-2.2.7
274
- paths:
275
- - ~/project/vendor/bundle
276
-
277
- build_2.3.4_rails_5:
278
- docker:
279
- - image: deliveroo/multiruby
280
- - image: redis:3-alpine
281
- steps:
282
- - checkout
283
-
284
- - run:
285
- name: Select build variant (Ruby 2.3.4, rails_5)
286
- command: |
287
- rbenv local 2.3.4 ;
288
- gem install bundler ;
289
- bundle config --local gemfile $PWD/gemfiles/rails_5.gemfile
290
-
291
- - restore_cache:
292
- keys:
293
- - v2-bundle-2.3.4-rails_5-{{ .Branch }}
294
- - v2-bundle-2.3.4-rails_5
295
- - v2-bundle-2.3.4
296
-
297
- - run:
298
- name: Install dependencies
299
- command: |
300
- bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
301
-
302
- - run:
303
- name: Run test suite
304
- command: |
305
- unset RACK_ENV &&
306
- unset RAILS_ENV &&
307
- bundle exec rspec
308
-
309
- - save_cache:
310
- key: v2-bundle-2.3.4-rails_5-{{ .Branch }}
311
- paths:
312
- - ~/project/vendor/bundle
313
- - save_cache:
314
- key: v2-bundle-2.3.4-rails_5
315
- paths:
316
- - ~/project/vendor/bundle
317
- - save_cache:
318
- key: v2-bundle-2.3.4
319
- paths:
320
- - ~/project/vendor/bundle
321
-
322
- build_2.4.1_rails_5:
323
- docker:
324
- - image: deliveroo/multiruby
325
- - image: redis:3-alpine
326
- steps:
327
- - checkout
328
-
329
- - run:
330
- name: Select build variant (Ruby 2.4.1, rails_5)
331
- command: |
332
- rbenv local 2.4.1 ;
333
- gem install bundler ;
17
+ gem install bundler -v '~> 1.17' ;
334
18
  bundle config --local gemfile $PWD/gemfiles/rails_5.gemfile
335
19
 
336
20
  - restore_cache:
337
21
  keys:
338
- - v2-bundle-2.4.1-rails_5-{{ .Branch }}
339
- - v2-bundle-2.4.1-rails_5
340
- - v2-bundle-2.4.1
22
+ - v2-bundle-2.5.0-rails_5-{{ .Branch }}
23
+ - v2-bundle-2.5.0-rails_5
24
+ - v2-bundle-2.5.0
341
25
 
342
26
  - run:
343
27
  name: Install dependencies
@@ -352,15 +36,15 @@ jobs:
352
36
  bundle exec rspec
353
37
 
354
38
  - save_cache:
355
- key: v2-bundle-2.4.1-rails_5-{{ .Branch }}
39
+ key: v2-bundle-2.5.0-rails_5-{{ .Branch }}
356
40
  paths:
357
41
  - ~/project/vendor/bundle
358
42
  - save_cache:
359
- key: v2-bundle-2.4.1-rails_5
43
+ key: v2-bundle-2.5.0-rails_5
360
44
  paths:
361
45
  - ~/project/vendor/bundle
362
46
  - save_cache:
363
- key: v2-bundle-2.4.1
47
+ key: v2-bundle-2.5.0
364
48
  paths:
365
49
  - ~/project/vendor/bundle
366
50
 
@@ -369,20 +53,5 @@ workflows:
369
53
  version: 2
370
54
  test:
371
55
  jobs:
372
-
373
- - build_2.2.7_rails_3
374
-
375
- - build_2.3.4_rails_3
376
-
377
- - build_2.2.7_rails_4
378
-
379
- - build_2.3.4_rails_4
380
-
381
- - build_2.4.1_rails_4
382
-
383
- - build_2.2.7_rails_5
384
-
385
- - build_2.3.4_rails_5
386
-
387
- - build_2.4.1_rails_5
56
+ - build_2.5_rails_5
388
57
 
@@ -2,14 +2,11 @@
2
2
  # erb .circleci/config.yml.erb > .circleci/config.yml
3
3
  <%
4
4
  builds = [
5
- ['2.2.7', 'rails_3'],
6
5
  ['2.3.4', 'rails_3'],
7
- ['2.2.7', 'rails_4'],
8
6
  ['2.3.4', 'rails_4'],
9
7
  ['2.4.1', 'rails_4'],
10
- ['2.2.7', 'rails_5'],
11
8
  ['2.3.4', 'rails_5'],
12
- ['2.4.1', 'rails_5'],
9
+ ['2.4.1', 'rails_5']
13
10
  ]
14
11
  %>
15
12
  version: 2
@@ -26,7 +23,7 @@ jobs:
26
23
  name: Select build variant (Ruby <%= ruby %>, <%= variant %>)
27
24
  command: |
28
25
  rbenv local <%= ruby %> ;
29
- gem install bundler ;
26
+ gem install bundler -v '~> 1.17' ;
30
27
  bundle config --local gemfile $PWD/gemfiles/<%= variant %>.gemfile
31
28
 
32
29
  - restore_cache:
data/CHANGELOG.md CHANGED
@@ -2,6 +2,28 @@
2
2
 
3
3
  _A description of your awesome changes here!_
4
4
 
5
+ ### 3.6.8
6
+
7
+ Features:
8
+
9
+ - Raises error on `502 Bad Gateway` [#94](https://github.com/deliveroo/routemaster-drain/pull/94)
10
+
11
+ ### 3.6.7 (2021-02-11)
12
+
13
+ Features:
14
+
15
+ - APIClient accepts timeout and open_timeout options
16
+
17
+ ### 3.6.5 (2019-02-08)
18
+
19
+ Bug fix:
20
+
21
+ - Make sure Faraday adapter is loaded after all middleware for ApiClient
22
+
23
+ Drop:
24
+
25
+ - Builds for Ruby 2.2
26
+
5
27
  ### 3.6.4 (2018-10-23)
6
28
 
7
29
  Features:
data/README.md CHANGED
@@ -139,6 +139,13 @@ map '/events' do
139
139
  end
140
140
  ```
141
141
 
142
+ You can use the `.subscribe` method multiple times to have your event batches
143
+ go through multiple listeners. But bear in the mind any performance cost of
144
+ multiple places of processing the event batches. For example, instead of having
145
+ multiple listener classes that iterate over the events in a batch, you can have
146
+ a single listener class that iterates over the batch only once and reacts to the
147
+ batch's events accordingly.
148
+
142
149
  This relies on the excellent event bus from the [wisper
143
150
  gem](https://github.com/krisleech/wisper#wisper).
144
151
 
@@ -45,6 +45,8 @@ module Routemaster
45
45
  @retry_attempts = options.fetch :retry_attempts, 2
46
46
  @retry_methods = options.fetch :retry_methods, Faraday::Request::Retry::IDEMPOTENT_METHODS
47
47
  @retry_exceptions = options.fetch :retry_exceptions, Faraday::Request::Retry::Options.new.exceptions
48
+ @timeout = options.fetch :timeout, nil
49
+ @open_timeout = options.fetch :open_timeout, nil
48
50
 
49
51
  connection # warm up connection so Faraday does all it's magical file loading in the main thread
50
52
  end
@@ -140,14 +142,15 @@ module Routemaster
140
142
  f.use Routemaster::Middleware::ResponseCaching, listener: @listener
141
143
  f.use Routemaster::Middleware::Metrics, client: @metrics_client, source_peer: @source_peer
142
144
  f.use Routemaster::Middleware::ErrorHandling
143
- f.adapter :typhoeus
144
145
 
145
146
  @middlewares.each do |middleware|
146
147
  f.use(*middleware)
147
148
  end
148
149
 
149
- f.options.timeout = ENV.fetch('ROUTEMASTER_CACHE_TIMEOUT', 1).to_f
150
- f.options.open_timeout = ENV.fetch('ROUTEMASTER_CACHE_TIMEOUT', 1).to_f
150
+ f.adapter :typhoeus
151
+
152
+ f.options.timeout = (@timeout || ENV.fetch('ROUTEMASTER_CACHE_TIMEOUT', 1)).to_f
153
+ f.options.open_timeout = (@open_timeout || ENV.fetch('ROUTEMASTER_CACHE_TIMEOUT', 1)).to_f
151
154
  f.ssl.verify = ENV.fetch('ROUTEMASTER_CACHE_VERIFY_SSL', 'false') == 'true'
152
155
  end
153
156
  end
@@ -25,13 +25,14 @@ module Routemaster
25
25
  ENV.fetch('ROUTEMASTER_ENABLE_API_CLIENT_CIRCUIT', 'NO') =~ /\A(YES|TRUE|ON|1)\Z/i
26
26
  end
27
27
 
28
+
28
29
  def circuit
29
30
  Circuitbox.circuit(@circuit_name, {
30
31
  sleep_window: configuration_setting(@circuit_name, 'ROUTEMASTER_CIRCUIT_BREAKER_SLEEP_WINDOW', 60).to_i,
31
32
  time_window: configuration_setting(@circuit_name, 'ROUTEMASTER_CIRCUIT_BREAKER_TIME_WINDOW', 120).to_i,
32
33
  volume_threshold: configuration_setting(@circuit_name, 'ROUTEMASTER_CIRCUIT_BREAKER_VOLUME_THRESHOLD', 50).to_i,
33
34
  error_threshold: configuration_setting(@circuit_name, 'ROUTEMASTER_CIRCUIT_BREAKER_ERROR_THRESHOLD', 50).to_i,
34
- cache: Moneta.new(:Redis, backend: Config.cache_redis),
35
+ cache: Moneta::Adapters::Redis.new(backend: Config.cache_redis),
35
36
  exceptions: [Routemaster::Errors::FatalResource, Faraday::TimeoutError]
36
37
  })
37
38
  end
@@ -1,5 +1,5 @@
1
1
  module Routemaster
2
2
  module Drain
3
- VERSION = '3.6.4'.freeze
3
+ VERSION = '3.6.8'.freeze
4
4
  end
5
5
  end
@@ -82,6 +82,12 @@ module Routemaster
82
82
  end
83
83
  end
84
84
 
85
+ class BadGateway < BaseError
86
+ def message
87
+ "Bad Gateway"
88
+ end
89
+ end
90
+
85
91
  class ServiceNotAvailable < BaseError
86
92
  def message
87
93
  "Service Not Available"
@@ -16,6 +16,7 @@ module Routemaster
16
16
  (413..413) => Errors::InvalidResource,
17
17
  (429..429) => Errors::ResourceThrottling,
18
18
  (407..500) => Errors::FatalResource,
19
+ (502..502) => Errors::BadGateway,
19
20
  (503..503) => Errors::ServiceNotAvailable
20
21
  }.freeze
21
22
 
@@ -26,4 +26,5 @@ Gem::Specification.new do |spec|
26
26
  spec.add_runtime_dependency 'redis-namespace'
27
27
  spec.add_runtime_dependency 'concurrent-ruby'
28
28
  spec.add_runtime_dependency 'circuitbox'
29
+ spec.add_runtime_dependency 'moneta', '1.0.0'
29
30
  end
@@ -53,7 +53,7 @@ describe Routemaster::APIClient do
53
53
  subject.status
54
54
  assert_requested(:get, /example/) do |req|
55
55
  expect(req.headers.keys).to include('X-Custom-Header')
56
- expect(req.headers['User-Agent']).to eql "RoutemasterDrain - Faraday v0.15.3"
56
+ expect(req.headers['User-Agent']).to eql "RoutemasterDrain - Faraday v#{Faraday::VERSION}"
57
57
  end
58
58
  end
59
59
 
@@ -21,7 +21,7 @@ describe Routemaster::APIClient do
21
21
  let(:port) { 8080 }
22
22
  let(:service) do
23
23
  TestServer.new(port) do |server|
24
- [400, 401, 403, 404, 405, 409, 412, 413, 429, 500, 503].each do |status_code|
24
+ [400, 401, 403, 404, 405, 409, 412, 413, 429, 500, 502, 503].each do |status_code|
25
25
  server.mount_proc "/#{status_code}" do |req, res|
26
26
  res.status = status_code
27
27
  res.body = { field: 'test' }.to_json
@@ -163,6 +163,10 @@ describe Routemaster::APIClient do
163
163
  expect { perform.(host + '/500') }.to raise_error(Routemaster::Errors::FatalResource)
164
164
  end
165
165
 
166
+ it 'raises a BadGateway on 502' do
167
+ expect { perform.(host + '/502') }.to raise_error(Routemaster::Errors::BadGateway)
168
+ end
169
+
166
170
  it 'raises a ServiceNotAvailable on 503' do
167
171
  expect { perform.(host + '/503') }.to raise_error(Routemaster::Errors::ServiceNotAvailable)
168
172
  end
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.6.4
4
+ version: 3.6.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-23 00:00:00.000000000 Z
11
+ date: 2021-07-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -150,6 +150,20 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: moneta
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - '='
158
+ - !ruby/object:Gem::Version
159
+ version: 1.0.0
160
+ type: :runtime
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - '='
165
+ - !ruby/object:Gem::Version
166
+ version: 1.0.0
153
167
  description:
154
168
  email:
155
169
  - julien.letessier@gmail.com