routemaster-drain 3.0.2 → 3.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.circleci/config.yml +388 -0
- data/.circleci/config.yml.erb +70 -0
- data/.codeclimate.yml +1 -2
- data/.gitignore +2 -0
- data/.ruby-version +1 -1
- data/CHANGELOG.md +6 -0
- data/README.md +1 -1
- data/lib/routemaster/config.rb +1 -1
- data/lib/routemaster/drain.rb +1 -1
- data/spec/core_ext/forwardable_spec.rb +17 -0
- data/spec/routemaster/integration/api_client_spec.rb +25 -25
- data/spec/support/server.rb +2 -1
- metadata +8 -8
- data/.travis.yml +0 -20
- data/Gemfile.lock +0 -171
- data/gemfiles/rails_3.gemfile.lock +0 -240
- data/gemfiles/rails_4.gemfile.lock +0 -257
- data/gemfiles/rails_5.gemfile.lock +0 -260
data/.codeclimate.yml
CHANGED
data/.gitignore
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.4.
|
1
|
+
2.4.1
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# routemaster-drain [![Version](https://badge.fury.io/rb/routemaster-drain.svg)](https://rubygems.org/gems/routemaster-drain) [![Build](https://
|
1
|
+
# routemaster-drain [![Version](https://badge.fury.io/rb/routemaster-drain.svg)](https://rubygems.org/gems/routemaster-drain) [![Build](https://circleci.com/gh/deliveroo/routemaster-drain.svg?style=shield&circle-token=7c256c63e5683bc25f0b4c3db0170446c91d36c8)](https://circleci.com/gh/deliveroo/routemaster-drain) [![Code Climate](https://codeclimate.com/github/deliveroo/routemaster-drain/badges/gpa.svg)](https://codeclimate.com/github/deliveroo/routemaster-drain) [![codecov](https://codecov.io/gh/deliveroo/routemaster-drain/branch/master/graph/badge.svg)](https://codecov.io/gh/deliveroo/routemaster-drain) [![Docs](http://img.shields.io/badge/API%20docs-rubydoc.info-blue.svg)](http://rubydoc.info/github/deliveroo/routemaster-drain)
|
2
2
|
|
3
3
|
A Rack-based event receiver for the
|
4
4
|
[Routemaster](https://github.com/deliveroo/routemaster) event bus.
|
data/lib/routemaster/config.rb
CHANGED
@@ -54,7 +54,7 @@ module Routemaster
|
|
54
54
|
end
|
55
55
|
|
56
56
|
def cache_auth
|
57
|
-
|
57
|
+
Hashie::Rash.new.tap do |result|
|
58
58
|
ENV.fetch('ROUTEMASTER_CACHE_AUTH', '').split(',').each do |entry|
|
59
59
|
host, username, password = entry.split(':')
|
60
60
|
result[Regexp.new(host)] = [username, password]
|
data/lib/routemaster/drain.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'core_ext/forwardable'
|
2
|
+
|
3
|
+
describe Forwardable do
|
4
|
+
class Foo
|
5
|
+
extend Forwardable
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@bar = :bar
|
9
|
+
end
|
10
|
+
|
11
|
+
def_delegator :@bar, :to_s, :qux
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'expect delegation to work' do
|
15
|
+
expect(Foo.new.qux).to eq 'bar'
|
16
|
+
end
|
17
|
+
end
|
@@ -18,7 +18,7 @@ describe Routemaster::APIClient do
|
|
18
18
|
uses_redis
|
19
19
|
uses_webmock
|
20
20
|
|
21
|
-
let(:port) {
|
21
|
+
let(:port) { 8080 }
|
22
22
|
let(:service) do
|
23
23
|
TestServer.new(port) do |server|
|
24
24
|
[400, 401, 403, 404, 409, 412, 413, 429, 500].each do |status_code|
|
@@ -42,7 +42,7 @@ describe Routemaster::APIClient do
|
|
42
42
|
server.mount_proc "/discover" do |req, res|
|
43
43
|
res['Content-Type'] = 'application/json'
|
44
44
|
res.status = 200
|
45
|
-
res.body = { _links: { resources: { href: "http://
|
45
|
+
res.body = { _links: { resources: { href: "http://127.0.0.1:#{port}/resources" } } }.to_json
|
46
46
|
end
|
47
47
|
|
48
48
|
server.mount_proc "/resources" do |req, res|
|
@@ -53,20 +53,20 @@ describe Routemaster::APIClient do
|
|
53
53
|
res.body = {
|
54
54
|
_links: {
|
55
55
|
self: {
|
56
|
-
href: "http://
|
56
|
+
href: "http://127.0.0.1:#{port}/resourcess?first_name=roo&page=1&per_page=2"
|
57
57
|
},
|
58
58
|
first: {
|
59
|
-
href: "http://
|
59
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=1&per_page=2"
|
60
60
|
},
|
61
61
|
last: {
|
62
|
-
href: "http://
|
62
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=3&per_page=2"
|
63
63
|
},
|
64
64
|
next: {
|
65
|
-
href: "http://
|
65
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=2&per_page=2"
|
66
66
|
},
|
67
67
|
resources: [
|
68
|
-
{ href: "http://
|
69
|
-
{ href: "http://
|
68
|
+
{ href: "http://127.0.0.1:#{port}/resources/1" },
|
69
|
+
{ href: "http://127.0.0.1:#{port}/resources/1" }
|
70
70
|
]
|
71
71
|
}
|
72
72
|
}.to_json
|
@@ -74,20 +74,20 @@ describe Routemaster::APIClient do
|
|
74
74
|
res.body = {
|
75
75
|
_links: {
|
76
76
|
self: {
|
77
|
-
href: "http://
|
77
|
+
href: "http://127.0.0.1:#{port}/resourcess?first_name=roo&page=2&per_page=2"
|
78
78
|
},
|
79
79
|
first: {
|
80
|
-
href: "http://
|
80
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=1&per_page=2"
|
81
81
|
},
|
82
82
|
last: {
|
83
|
-
href: "http://
|
83
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=3&per_page=2"
|
84
84
|
},
|
85
85
|
next: {
|
86
|
-
href: "http://
|
86
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=3&per_page=2"
|
87
87
|
},
|
88
88
|
resources: [
|
89
|
-
{ href: "http://
|
90
|
-
{ href: "http://
|
89
|
+
{ href: "http://127.0.0.1:#{port}/resources/1" },
|
90
|
+
{ href: "http://127.0.0.1:#{port}/resources/1" }
|
91
91
|
]
|
92
92
|
}
|
93
93
|
}.to_json
|
@@ -95,16 +95,16 @@ describe Routemaster::APIClient do
|
|
95
95
|
res.body = {
|
96
96
|
_links: {
|
97
97
|
self: {
|
98
|
-
href: "http://
|
98
|
+
href: "http://127.0.0.1:#{port}/resourcess?first_name=roo&page=3&per_page=2"
|
99
99
|
},
|
100
100
|
first: {
|
101
|
-
href: "http://
|
101
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=1&per_page=2"
|
102
102
|
},
|
103
103
|
last: {
|
104
|
-
href: "http://
|
104
|
+
href: "http://127.0.0.1:#{port}/resources?first_name=roo&page=3&per_page=2"
|
105
105
|
},
|
106
106
|
resources: [
|
107
|
-
{ href: "http://
|
107
|
+
{ href: "http://127.0.0.1:#{port}/resources/1" }
|
108
108
|
]
|
109
109
|
}
|
110
110
|
}.to_json
|
@@ -118,7 +118,7 @@ describe Routemaster::APIClient do
|
|
118
118
|
|
119
119
|
before { WebMock.disable_net_connect!(allow_localhost: true) }
|
120
120
|
|
121
|
-
let(:host) { "http://
|
121
|
+
let(:host) { "http://127.0.0.1:#{port}" }
|
122
122
|
|
123
123
|
describe 'error handling' do
|
124
124
|
|
@@ -290,7 +290,7 @@ describe Routemaster::APIClient do
|
|
290
290
|
end
|
291
291
|
|
292
292
|
describe 'INDEX request' do
|
293
|
-
let(:url) { "http://
|
293
|
+
let(:url) { "http://127.0.0.1:#{port}/discover" }
|
294
294
|
|
295
295
|
subject do
|
296
296
|
Routemaster::APIClient.new(response_class: Routemaster::Responses::HateoasResponse)
|
@@ -305,13 +305,13 @@ describe Routemaster::APIClient do
|
|
305
305
|
it 'does not make any http requests to fetch individual resources if just the index method is called' do
|
306
306
|
res = subject.discover(url)
|
307
307
|
|
308
|
-
expect(subject).not_to receive(:get).with("http://
|
308
|
+
expect(subject).not_to receive(:get).with("http://127.0.0.1:#{port}/resources/#{anything}", anything)
|
309
309
|
res.resources.index
|
310
310
|
end
|
311
311
|
end
|
312
312
|
|
313
313
|
describe 'DISCOVER request' do
|
314
|
-
let(:url) { "http://
|
314
|
+
let(:url) { "http://127.0.0.1:#{port}/discover" }
|
315
315
|
|
316
316
|
subject do
|
317
317
|
Routemaster::APIClient.new(response_class: Routemaster::Responses::HateoasResponse)
|
@@ -365,21 +365,21 @@ describe Routemaster::APIClient do
|
|
365
365
|
it 'sends request metrics' do
|
366
366
|
subject.get(url)
|
367
367
|
expect(metrics_client).to have_received(:increment).with(
|
368
|
-
'api_client.request.count', tags: %w[source:test_service destination:
|
368
|
+
'api_client.request.count', tags: %w[source:test_service destination:127.0.0.1 verb:get]
|
369
369
|
)
|
370
370
|
end
|
371
371
|
|
372
372
|
it 'sends response metrics' do
|
373
373
|
subject.get(url)
|
374
374
|
expect(metrics_client).to have_received(:increment).with(
|
375
|
-
'api_client.response.count', tags: %w[source:test_service destination:
|
375
|
+
'api_client.response.count', tags: %w[source:test_service destination:127.0.0.1 status:200]
|
376
376
|
)
|
377
377
|
end
|
378
378
|
|
379
379
|
it 'sends timing metrics' do
|
380
380
|
subject.get(url)
|
381
381
|
expect(metrics_client).to have_received(:time).with(
|
382
|
-
'api_client.latency', tags: %w[source:test_service destination:
|
382
|
+
'api_client.latency', tags: %w[source:test_service destination:127.0.0.1 verb:get]
|
383
383
|
)
|
384
384
|
end
|
385
385
|
end
|
data/spec/support/server.rb
CHANGED
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.0.3
|
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-09-
|
11
|
+
date: 2017-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -143,6 +143,8 @@ executables: []
|
|
143
143
|
extensions: []
|
144
144
|
extra_rdoc_files: []
|
145
145
|
files:
|
146
|
+
- ".circleci/config.yml"
|
147
|
+
- ".circleci/config.yml.erb"
|
146
148
|
- ".codeclimate.yml"
|
147
149
|
- ".codecov.yml"
|
148
150
|
- ".env.test"
|
@@ -151,23 +153,18 @@ files:
|
|
151
153
|
- ".rspec"
|
152
154
|
- ".rubocop.yml"
|
153
155
|
- ".ruby-version"
|
154
|
-
- ".travis.yml"
|
155
156
|
- ".yardopts"
|
156
157
|
- Appraisals
|
157
158
|
- CHANGELOG.md
|
158
159
|
- Gemfile
|
159
|
-
- Gemfile.lock
|
160
160
|
- Guardfile
|
161
161
|
- LICENSE.txt
|
162
162
|
- README.md
|
163
163
|
- Rakefile
|
164
164
|
- appraise
|
165
165
|
- gemfiles/rails_3.gemfile
|
166
|
-
- gemfiles/rails_3.gemfile.lock
|
167
166
|
- gemfiles/rails_4.gemfile
|
168
|
-
- gemfiles/rails_4.gemfile.lock
|
169
167
|
- gemfiles/rails_5.gemfile
|
170
|
-
- gemfiles/rails_5.gemfile.lock
|
171
168
|
- lib/core_ext/forwardable.rb
|
172
169
|
- lib/routemaster/api_client.rb
|
173
170
|
- lib/routemaster/cache.rb
|
@@ -211,6 +208,7 @@ files:
|
|
211
208
|
- lib/routemaster/responses/response_promise.rb
|
212
209
|
- lib/routemaster/tasks/fix_cache_ttl.rb
|
213
210
|
- routemaster-drain.gemspec
|
211
|
+
- spec/core_ext/forwardable_spec.rb
|
214
212
|
- spec/routemaster/api_client_spec.rb
|
215
213
|
- spec/routemaster/cache_spec.rb
|
216
214
|
- spec/routemaster/config_spec.rb
|
@@ -272,11 +270,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
272
270
|
version: '0'
|
273
271
|
requirements: []
|
274
272
|
rubyforge_project:
|
275
|
-
rubygems_version: 2.6.
|
273
|
+
rubygems_version: 2.6.13
|
276
274
|
signing_key:
|
277
275
|
specification_version: 4
|
278
276
|
summary: Event receiver for the Routemaster bus
|
279
277
|
test_files:
|
278
|
+
- spec/core_ext/forwardable_spec.rb
|
280
279
|
- spec/routemaster/api_client_spec.rb
|
281
280
|
- spec/routemaster/cache_spec.rb
|
282
281
|
- spec/routemaster/config_spec.rb
|
@@ -318,3 +317,4 @@ test_files:
|
|
318
317
|
- spec/support/uses_dotenv.rb
|
319
318
|
- spec/support/uses_redis.rb
|
320
319
|
- spec/support/uses_webmock.rb
|
320
|
+
has_rdoc:
|
data/.travis.yml
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
language: ruby
|
2
|
-
cache: bundler
|
3
|
-
services:
|
4
|
-
- redis-server
|
5
|
-
rvm:
|
6
|
-
- 2.2.6
|
7
|
-
- 2.3.3
|
8
|
-
- 2.4.0
|
9
|
-
- ruby-head
|
10
|
-
gemfile:
|
11
|
-
- gemfiles/rails_3.gemfile
|
12
|
-
- gemfiles/rails_4.gemfile
|
13
|
-
- gemfiles/rails_5.gemfile
|
14
|
-
script:
|
15
|
-
- bundle exec rspec
|
16
|
-
matrix:
|
17
|
-
allow_failures:
|
18
|
-
- rvm: ruby-head
|
19
|
-
- rvm: 2.4.0
|
20
|
-
gemfile: gemfiles/rails_3.gemfile
|
data/Gemfile.lock
DELETED
@@ -1,171 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
routemaster-drain (3.0.2)
|
5
|
-
addressable
|
6
|
-
concurrent-ruby
|
7
|
-
faraday (>= 0.9.0)
|
8
|
-
faraday_middleware
|
9
|
-
hashie
|
10
|
-
rack (>= 1.4.5)
|
11
|
-
redis-namespace
|
12
|
-
typhoeus (~> 1.1)
|
13
|
-
wisper (~> 1.6.1)
|
14
|
-
|
15
|
-
GEM
|
16
|
-
remote: https://rubygems.org/
|
17
|
-
specs:
|
18
|
-
addressable (2.5.0)
|
19
|
-
public_suffix (~> 2.0, >= 2.0.2)
|
20
|
-
appraisal (2.1.0)
|
21
|
-
bundler
|
22
|
-
rake
|
23
|
-
thor (>= 0.14.0)
|
24
|
-
byebug (9.0.6)
|
25
|
-
codecov (0.1.9)
|
26
|
-
json
|
27
|
-
simplecov
|
28
|
-
url
|
29
|
-
coderay (1.1.1)
|
30
|
-
concurrent-ruby (1.0.5)
|
31
|
-
connection_pool (2.2.1)
|
32
|
-
crack (0.4.3)
|
33
|
-
safe_yaml (~> 1.0.0)
|
34
|
-
diff-lcs (1.2.5)
|
35
|
-
docile (1.1.5)
|
36
|
-
dogstatsd (2.0.0)
|
37
|
-
dotenv (2.1.1)
|
38
|
-
ethon (0.10.1)
|
39
|
-
ffi (>= 1.3.0)
|
40
|
-
faraday (0.12.2)
|
41
|
-
multipart-post (>= 1.2, < 3)
|
42
|
-
faraday_middleware (0.12.2)
|
43
|
-
faraday (>= 0.7.4, < 1.0)
|
44
|
-
ffi (1.9.17)
|
45
|
-
fork (1.0.1)
|
46
|
-
fork_break (0.1.4)
|
47
|
-
fork (= 1.0.1)
|
48
|
-
formatador (0.2.5)
|
49
|
-
guard (2.14.0)
|
50
|
-
formatador (>= 0.2.4)
|
51
|
-
listen (>= 2.7, < 4.0)
|
52
|
-
lumberjack (~> 1.0)
|
53
|
-
nenv (~> 0.1)
|
54
|
-
notiffany (~> 0.0)
|
55
|
-
pry (>= 0.9.12)
|
56
|
-
shellany (~> 0.0)
|
57
|
-
thor (>= 0.18.1)
|
58
|
-
guard-compat (1.2.1)
|
59
|
-
guard-rspec (4.7.3)
|
60
|
-
guard (~> 2.1)
|
61
|
-
guard-compat (~> 1.1)
|
62
|
-
rspec (>= 2.99.0, < 4.0)
|
63
|
-
hashdiff (0.3.2)
|
64
|
-
hashie (3.5.6)
|
65
|
-
json (2.0.3)
|
66
|
-
listen (3.1.5)
|
67
|
-
rb-fsevent (~> 0.9, >= 0.9.4)
|
68
|
-
rb-inotify (~> 0.9, >= 0.9.7)
|
69
|
-
ruby_dep (~> 1.2)
|
70
|
-
lumberjack (1.0.10)
|
71
|
-
method_source (0.8.2)
|
72
|
-
mono_logger (1.1.0)
|
73
|
-
multi_json (1.12.1)
|
74
|
-
multipart-post (2.0.0)
|
75
|
-
nenv (0.3.0)
|
76
|
-
notiffany (0.1.1)
|
77
|
-
nenv (~> 0.1)
|
78
|
-
shellany (~> 0.0)
|
79
|
-
pry (0.10.4)
|
80
|
-
coderay (~> 1.1.0)
|
81
|
-
method_source (~> 0.8.1)
|
82
|
-
slop (~> 3.4)
|
83
|
-
psych (2.2.1)
|
84
|
-
public_suffix (2.0.5)
|
85
|
-
rack (1.6.5)
|
86
|
-
rack-protection (1.5.3)
|
87
|
-
rack
|
88
|
-
rack-test (0.6.3)
|
89
|
-
rack (>= 1.0)
|
90
|
-
rake (12.0.0)
|
91
|
-
rb-fsevent (0.9.8)
|
92
|
-
rb-inotify (0.9.7)
|
93
|
-
ffi (>= 0.5.0)
|
94
|
-
redis (3.3.2)
|
95
|
-
redis-namespace (1.5.2)
|
96
|
-
redis (~> 3.0, >= 3.0.4)
|
97
|
-
resque (1.26.0)
|
98
|
-
mono_logger (~> 1.0)
|
99
|
-
multi_json (~> 1.0)
|
100
|
-
redis-namespace (~> 1.3)
|
101
|
-
sinatra (>= 0.9.2)
|
102
|
-
vegas (~> 0.1.2)
|
103
|
-
rspec (3.5.0)
|
104
|
-
rspec-core (~> 3.5.0)
|
105
|
-
rspec-expectations (~> 3.5.0)
|
106
|
-
rspec-mocks (~> 3.5.0)
|
107
|
-
rspec-core (3.5.4)
|
108
|
-
rspec-support (~> 3.5.0)
|
109
|
-
rspec-expectations (3.5.0)
|
110
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
111
|
-
rspec-support (~> 3.5.0)
|
112
|
-
rspec-mocks (3.5.0)
|
113
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
114
|
-
rspec-support (~> 3.5.0)
|
115
|
-
rspec-support (3.5.0)
|
116
|
-
ruby_dep (1.5.0)
|
117
|
-
safe_yaml (1.0.4)
|
118
|
-
shellany (0.0.1)
|
119
|
-
sidekiq (4.2.7)
|
120
|
-
concurrent-ruby (~> 1.0)
|
121
|
-
connection_pool (~> 2.2, >= 2.2.0)
|
122
|
-
rack-protection (>= 1.5.0)
|
123
|
-
redis (~> 3.2, >= 3.2.1)
|
124
|
-
simplecov (0.13.0)
|
125
|
-
docile (~> 1.1.0)
|
126
|
-
json (>= 1.8, < 3)
|
127
|
-
simplecov-html (~> 0.10.0)
|
128
|
-
simplecov-html (0.10.0)
|
129
|
-
sinatra (1.4.6)
|
130
|
-
rack (~> 1.4)
|
131
|
-
rack-protection (~> 1.4)
|
132
|
-
tilt (>= 1.3, < 3)
|
133
|
-
slop (3.6.0)
|
134
|
-
thor (0.19.4)
|
135
|
-
tilt (2.0.5)
|
136
|
-
typhoeus (1.3.0)
|
137
|
-
ethon (>= 0.9.0)
|
138
|
-
url (0.3.2)
|
139
|
-
vegas (0.1.11)
|
140
|
-
rack (>= 1.0.0)
|
141
|
-
webmock (2.3.2)
|
142
|
-
addressable (>= 2.3.6)
|
143
|
-
crack (>= 0.3.2)
|
144
|
-
hashdiff
|
145
|
-
wisper (1.6.1)
|
146
|
-
|
147
|
-
PLATFORMS
|
148
|
-
ruby
|
149
|
-
|
150
|
-
DEPENDENCIES
|
151
|
-
appraisal
|
152
|
-
bundler
|
153
|
-
byebug
|
154
|
-
codecov
|
155
|
-
dogstatsd
|
156
|
-
dotenv
|
157
|
-
fork_break
|
158
|
-
guard-rspec
|
159
|
-
pry
|
160
|
-
psych
|
161
|
-
rack-test
|
162
|
-
rake
|
163
|
-
resque
|
164
|
-
routemaster-drain!
|
165
|
-
rspec
|
166
|
-
sidekiq
|
167
|
-
simplecov
|
168
|
-
webmock
|
169
|
-
|
170
|
-
BUNDLED WITH
|
171
|
-
1.15.4
|