routemaster-drain 3.6.2 → 3.6.7

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
- SHA1:
3
- metadata.gz: 3767d797098f45ef97ab1109e2adc72e02db4fc8
4
- data.tar.gz: 9efed3541d15645fabc5ec362eea53ff25509237
2
+ SHA256:
3
+ metadata.gz: c4469f5d849b4e194fab122200d8ad3b674b0614192c8d772c93d5632bc9d7c7
4
+ data.tar.gz: 1dcc2036e9718877e22c3af4f2dce9605ae28d851173ede745b3e6dbcd2b4b75
5
5
  SHA512:
6
- metadata.gz: 858c27a01bf3d3d0117d40956be50e63535fa07df173d8c43047e6feb3caf214c88b057c888e3bf61a794076db7d740020137faeef7b8425e9469e8361b29c3e
7
- data.tar.gz: 9c261c1b13f3a0629efe44a04ae2896a30480d3552b82f9df226e87bb5c94649d00e1b893d0952f30a04787e89e24b6946992e4e1f945161ff026bc7b15422c4
6
+ metadata.gz: cbac86db4c0502ac01f77e1b4daeb1559dfe7d5edb795a25891ddd7cf0cf7bc948f475349c89a98a4727e1dcacf26bffd36b4d0928a4e9384a0b74482adecc8e
7
+ data.tar.gz: 8df8cf287f7fadd4183946e217cbb79247bf875139ff29ae03b3b8951a2b68270c58caf263da5a7dc0847eb4bdb88ed2248fb5b3fd4c41d66a71e03deb90822e
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
@@ -1,6 +1,34 @@
1
1
  ### HEAD
2
2
 
3
3
  _A description of your awesome changes here!_
4
+ ### 3.6.7 (2021-02-11)
5
+
6
+ Features:
7
+
8
+ - APIClient accepts timeout and open_timeout options
9
+
10
+ ### 3.6.5 (2019-02-08)
11
+
12
+ Bug fix:
13
+
14
+ - Make sure Faraday adapter is loaded after all middleware for ApiClient
15
+
16
+ Drop:
17
+
18
+ - Builds for Ruby 2.2
19
+
20
+ ### 3.6.4 (2018-10-23)
21
+
22
+ Features:
23
+
24
+ - Allow specification of User-Agent through environment variable
25
+ - Add fallback values for User-Agent header in API client
26
+
27
+ ### 3.6.3 (2018-10-17)
28
+
29
+ Bug fix:
30
+
31
+ - Allow all middleware classes to be initialised in the same format
4
32
 
5
33
  ### 3.6.2 (2018-10-11)
6
34
 
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
 
@@ -264,6 +271,9 @@ configure it using `client_options`:
264
271
  $cache = Routemaster::Cache.new(client_options: {source_peer: "<your user agent>"})
265
272
  ```
266
273
 
274
+ You can specify your user agent with the `ROUTEMASTER_API_CLIENT_USER_AGENT` environment
275
+ variable as well.
276
+
267
277
  ### Expire Cache data for all notified resources
268
278
 
269
279
  You may wish to maintain a coherent cache, but don't need the cache to be warmed
@@ -30,6 +30,7 @@ require 'hashie/mash'
30
30
 
31
31
  module Routemaster
32
32
  class APIClient
33
+ DEFAULT_USER_AGENT = ENV.fetch('ROUTEMASTER_API_CLIENT_USER_AGENT') { "RoutemasterDrain - Faraday v#{Faraday::VERSION}" }.freeze
33
34
 
34
35
  # Memoize the root resources at Class level so that we don't hit the cache
35
36
  # all the time to fetch the root resource before doing anything else.
@@ -44,6 +45,8 @@ module Routemaster
44
45
  @retry_attempts = options.fetch :retry_attempts, 2
45
46
  @retry_methods = options.fetch :retry_methods, Faraday::Request::Retry::IDEMPOTENT_METHODS
46
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
47
50
 
48
51
  connection # warm up connection so Faraday does all it's magical file loading in the main thread
49
52
  end
@@ -139,14 +142,15 @@ module Routemaster
139
142
  f.use Routemaster::Middleware::ResponseCaching, listener: @listener
140
143
  f.use Routemaster::Middleware::Metrics, client: @metrics_client, source_peer: @source_peer
141
144
  f.use Routemaster::Middleware::ErrorHandling
142
- f.adapter :typhoeus
143
145
 
144
146
  @middlewares.each do |middleware|
145
147
  f.use(*middleware)
146
148
  end
147
149
 
148
- f.options.timeout = ENV.fetch('ROUTEMASTER_CACHE_TIMEOUT', 1).to_f
149
- 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
150
154
  f.ssl.verify = ENV.fetch('ROUTEMASTER_CACHE_VERIFY_SSL', 'false') == 'true'
151
155
  end
152
156
  end
@@ -157,8 +161,7 @@ module Routemaster
157
161
  end
158
162
 
159
163
  def user_agent_header
160
- agent = @source_peer || "Faraday v#{Faraday::VERSION}"
161
- { 'User-Agent' => agent }
164
+ { 'User-Agent' => @source_peer || DEFAULT_USER_AGENT }
162
165
  end
163
166
 
164
167
  def response_cache_opt_headers(value)
@@ -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.2'.freeze
3
+ VERSION = '3.6.7'.freeze
4
4
  end
5
5
  end
@@ -16,10 +16,10 @@ module Routemaster
16
16
  class Authenticate
17
17
  include Wisper::Publisher
18
18
 
19
- # @param uuid [Enumerable] a set of accepted authentication tokens
20
- def initialize(app, uuid: nil, **_)
19
+ # options[:uuid] [Enumerable] a set of accepted authentication tokens
20
+ def initialize(app, options = {})
21
21
  @app = app
22
- @uuid = uuid || Config.drain_tokens
22
+ @uuid = options.fetch(:uuid) { Config.drain_tokens }
23
23
 
24
24
  unless @uuid.kind_of?(String) || @uuid.kind_of?(Enumerable)
25
25
  raise ArgumentError, ':uuid must be a String or Enumerable'
@@ -7,11 +7,11 @@ require 'routemaster/event_index'
7
7
  module Routemaster
8
8
  module Middleware
9
9
  class Cache
10
- def initialize(app, cache:nil, client:nil, queue:nil, **_)
10
+ def initialize(app, options = {})
11
11
  @app = app
12
- @cache = cache || Routemaster::Cache.new
13
- @client = client || Routemaster::Jobs::Client.new
14
- @queue = queue || Config.queue_name
12
+ @cache = options.fetch(:cache) { Routemaster::Cache.new }
13
+ @client = options.fetch(:client) { Routemaster::Jobs::Client.new }
14
+ @queue = options.fetch(:queue) { Config.queue_name }
15
15
  end
16
16
 
17
17
  def call(env)
@@ -11,9 +11,9 @@ module Routemaster
11
11
  # The dirty map is passed as `:map` to the constructor and must respond to
12
12
  # `#mark` (like `Routemaster::Dirty::Map`).
13
13
  class Dirty
14
- def initialize(app, dirty_map: nil, **_)
14
+ def initialize(app, options = {})
15
15
  @app = app
16
- @map = dirty_map || Routemaster::Dirty::Map.new
16
+ @map = options.fetch(:dirty_map) { Routemaster::Dirty::Map.new }
17
17
  end
18
18
 
19
19
  def call(env)
@@ -3,9 +3,9 @@ require 'routemaster/cache'
3
3
  module Routemaster
4
4
  module Middleware
5
5
  class ExpireCache
6
- def initialize(app, cache:nil, **_)
6
+ def initialize(app, options = {})
7
7
  @app = app
8
- @cache = cache || Routemaster::Cache.new
8
+ @cache = options.fetch(:cache) { Routemaster::Cache.new }
9
9
  end
10
10
 
11
11
  def call(env)
@@ -7,11 +7,11 @@ module Routemaster
7
7
  #
8
8
  # Will use `Routemaster::Dirty::Filter` by default.
9
9
  class Filter
10
- # @param filter [Routemaster::Dirty::Filter] an event filter (optional;
10
+ # options[:filter] [Routemaster::Dirty::Filter] an event filter (optional;
11
11
  # will be created using the `redis` and `expiry` options if not provided)
12
- def initialize(app, filter:nil, **_)
12
+ def initialize(app, options = {})
13
13
  @app = app
14
- @filter = filter || Routemaster::Dirty::Filter.new
14
+ @filter = options.fetch(:filter) { Routemaster::Dirty::Filter.new }
15
15
  end
16
16
 
17
17
  def call(env)
@@ -3,10 +3,10 @@ module Routemaster
3
3
  class Metrics
4
4
  INTERACTION_KEY = 'api_client'.freeze
5
5
 
6
- def initialize(app, client: nil, source_peer: nil)
6
+ def initialize(app, options = {})
7
7
  @app = app
8
- @client = client
9
- @source_peer = source_peer
8
+ @client = options[:client]
9
+ @source_peer = options[:source_peer]
10
10
  end
11
11
 
12
12
  def call(request_env)
@@ -10,7 +10,7 @@ module Routemaster
10
10
  # Lower middlewares (or the app) can access the parsed payload as a hash
11
11
  # in +env['routemaster.payload']+
12
12
  class Parse
13
- def initialize(app)
13
+ def initialize(app, _options = {})
14
14
  @app = app
15
15
  end
16
16
 
@@ -10,11 +10,11 @@ module Routemaster
10
10
  VERSION_REGEX = /application\/json;v=(?<version>\S*)/
11
11
  RESPONSE_CACHING_OPT_HEADER = 'X-routemaster_drain.opt_cache'.freeze
12
12
 
13
- def initialize(app, cache: Config.cache_redis, listener: nil)
13
+ def initialize(app, options = {})
14
14
  @app = app
15
- @cache = cache
15
+ @cache = options.fetch(:cache) { Config.cache_redis }
16
16
  @expiry = Config.cache_expiry
17
- @listener = listener
17
+ @listener = options[:listener]
18
18
  end
19
19
 
20
20
  def call(env)
@@ -2,7 +2,7 @@ module Routemaster
2
2
  module Middleware
3
3
  # Rejects all requests but POST to the root path
4
4
  class RootPostOnly
5
- def initialize(app)
5
+ def initialize(app, _options = {})
6
6
  @app = app
7
7
  end
8
8
 
@@ -6,9 +6,9 @@ module Routemaster
6
6
  #
7
7
  # Topic handlers are initialized with the full event payload and must respond to `#call`
8
8
  class Siphon
9
- def initialize(app, siphon_events: nil)
9
+ def initialize(app, options = {})
10
10
  @app = app
11
- @processors = siphon_events || {}
11
+ @processors = options.fetch(:siphon_events) { {} }
12
12
  end
13
13
 
14
14
  def call(env)
@@ -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
@@ -52,7 +52,8 @@ describe Routemaster::APIClient do
52
52
  headers['x-custom-header'] = 'why do you even'
53
53
  subject.status
54
54
  assert_requested(:get, /example/) do |req|
55
- expect(req.headers).to include('X-Custom-Header')
55
+ expect(req.headers.keys).to include('X-Custom-Header')
56
+ expect(req.headers['User-Agent']).to eql "RoutemasterDrain - Faraday v#{Faraday::VERSION}"
56
57
  end
57
58
  end
58
59
 
@@ -76,7 +77,7 @@ describe Routemaster::APIClient do
76
77
  it 'should set the user agent header to the faraday version' do
77
78
  subject.status
78
79
  assert_requested(:get, /example/) do |req|
79
- expect(req.headers).to include('User-Agent' => "Faraday v#{Faraday::VERSION}" )
80
+ expect(req.headers).to include('User-Agent' => "RoutemasterDrain - Faraday v#{Faraday::VERSION}" )
80
81
  end
81
82
  end
82
83
  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.2
4
+ version: 3.6.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Julien Letessier
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-10-11 00:00:00.000000000 Z
11
+ date: 2021-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -150,7 +150,21 @@ dependencies:
150
150
  - - ">="
151
151
  - !ruby/object:Gem::Version
152
152
  version: '0'
153
- description:
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
167
+ description:
154
168
  email:
155
169
  - julien.letessier@gmail.com
156
170
  executables: []
@@ -271,7 +285,7 @@ homepage: http://github.com/deliveroo/routemaster-drain
271
285
  licenses:
272
286
  - MIT
273
287
  metadata: {}
274
- post_install_message:
288
+ post_install_message:
275
289
  rdoc_options: []
276
290
  require_paths:
277
291
  - lib
@@ -286,9 +300,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
286
300
  - !ruby/object:Gem::Version
287
301
  version: '0'
288
302
  requirements: []
289
- rubyforge_project:
290
- rubygems_version: 2.6.11
291
- signing_key:
303
+ rubygems_version: 3.0.9
304
+ signing_key:
292
305
  specification_version: 4
293
306
  summary: Event receiver for the Routemaster bus
294
307
  test_files: