routemaster-drain 3.6.8 → 3.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.circleci/config.yml +50 -8
- data/CHANGELOG.md +6 -0
- data/gemfiles/rails_6.gemfile +24 -0
- data/lib/routemaster/api_client.rb +7 -5
- data/lib/routemaster/api_client_circuit.rb +0 -1
- data/lib/routemaster/drain.rb +1 -1
- data/spec/core_ext/forwardable_spec.rb +12 -10
- data/spec/routemaster/api_client_circuit_spec.rb +4 -1
- data/spec/routemaster/api_client_spec.rb +37 -0
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 91d53145809f5384fe911262c83306264381e1915ce6b6aef4a7de3299fd8eee
|
4
|
+
data.tar.gz: 2a7860c5a46d018aa7e10d82aad853066e5daf5851b6deba44e900985c7218c3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4119a30f7b34f48fcca01432718968523f71ebc9b298c78b6aa1d162c48108db631622ce94ec1859c5715642aa554f009b216cdf016b5391945722302a45ae42
|
7
|
+
data.tar.gz: fa0f8e231efdc36f2bf1f88e0a6a8f9cc14ae3b494761756317cc1924b8f8e505f2e6ca3651132a2e3e2bcddc313071b66523d4626308c324fa8722556ab6ebc
|
data/.circleci/config.yml
CHANGED
@@ -3,7 +3,6 @@
|
|
3
3
|
|
4
4
|
version: 2
|
5
5
|
jobs:
|
6
|
-
|
7
6
|
build_2.5_rails_5:
|
8
7
|
docker:
|
9
8
|
- image: circleci/ruby:2.4.1
|
@@ -19,9 +18,9 @@ jobs:
|
|
19
18
|
|
20
19
|
- restore_cache:
|
21
20
|
keys:
|
22
|
-
-
|
23
|
-
-
|
24
|
-
-
|
21
|
+
- v3-bundle-2.5.0-rails_5-{{ .Branch }}
|
22
|
+
- v3-bundle-2.5.0-rails_5
|
23
|
+
- v3-bundle-2.5.0
|
25
24
|
|
26
25
|
- run:
|
27
26
|
name: Install dependencies
|
@@ -36,22 +35,65 @@ jobs:
|
|
36
35
|
bundle exec rspec
|
37
36
|
|
38
37
|
- save_cache:
|
39
|
-
key:
|
38
|
+
key: v3-bundle-2.5.0-rails_5-{{ .Branch }}
|
40
39
|
paths:
|
41
40
|
- ~/project/vendor/bundle
|
42
41
|
- save_cache:
|
43
|
-
key:
|
42
|
+
key: v3-bundle-2.5.0-rails_5
|
44
43
|
paths:
|
45
44
|
- ~/project/vendor/bundle
|
46
45
|
- save_cache:
|
47
|
-
key:
|
46
|
+
key: v3-bundle-2.5.0
|
48
47
|
paths:
|
49
48
|
- ~/project/vendor/bundle
|
50
49
|
|
50
|
+
build_2.7_rails_6:
|
51
|
+
docker:
|
52
|
+
- image: circleci/ruby:2.7.4
|
53
|
+
- image: redis:6-alpine
|
54
|
+
steps:
|
55
|
+
- checkout
|
56
|
+
|
57
|
+
- run:
|
58
|
+
name: Install bundler
|
59
|
+
command: |
|
60
|
+
gem install bundler -v '~> 2' ;
|
61
|
+
bundle config --local gemfile $PWD/gemfiles/rails_6.gemfile
|
62
|
+
|
63
|
+
- restore_cache:
|
64
|
+
keys:
|
65
|
+
- bundle-2.7.4-rails_6-{{ .Branch }}
|
66
|
+
- bundle-2.7.4-rails_6
|
67
|
+
- bundle-2.7.4
|
68
|
+
|
69
|
+
- run:
|
70
|
+
name: Install dependencies
|
71
|
+
command: |
|
72
|
+
bundle install --jobs=3 --retry=3 --path=$PWD/vendor/bundle
|
73
|
+
|
74
|
+
- run:
|
75
|
+
name: Run test suite
|
76
|
+
command: |
|
77
|
+
unset RACK_ENV &&
|
78
|
+
unset RAILS_ENV &&
|
79
|
+
bundle exec rspec
|
80
|
+
|
81
|
+
- save_cache:
|
82
|
+
key: bundle-2.7.4-rails_6-{{ .Branch }}
|
83
|
+
paths:
|
84
|
+
- ~/project/vendor/bundle
|
85
|
+
- save_cache:
|
86
|
+
key: bundle-2.7.4-rails_6
|
87
|
+
paths:
|
88
|
+
- ~/project/vendor/bundle
|
89
|
+
- save_cache:
|
90
|
+
key: bundle-2.7.4
|
91
|
+
paths:
|
92
|
+
- ~/project/vendor/bundle
|
51
93
|
|
52
94
|
workflows:
|
53
95
|
version: 2
|
54
96
|
test:
|
55
97
|
jobs:
|
56
98
|
- build_2.5_rails_5
|
57
|
-
|
99
|
+
- build_2.7_rails_6
|
data/CHANGELOG.md
CHANGED
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "psych", :require => false
|
6
|
+
gem "bundler", :require => false
|
7
|
+
gem "rake", :require => false
|
8
|
+
gem "webmock", :require => false
|
9
|
+
gem "rack-test", :require => false
|
10
|
+
gem "dotenv", :require => false
|
11
|
+
gem "simplecov", :require => false
|
12
|
+
gem "codecov", :require => false
|
13
|
+
gem "resque", :require => false
|
14
|
+
gem "sidekiq", :require => false
|
15
|
+
gem "guard-rspec", :require => false
|
16
|
+
gem "pry", :require => false
|
17
|
+
gem "byebug", :require => false
|
18
|
+
gem "rspec", :require => false
|
19
|
+
gem "appraisal", :require => false
|
20
|
+
gem "dogstatsd", :require => false
|
21
|
+
gem "fork_break", :require => false
|
22
|
+
gem "rails", "~> 6.0"
|
23
|
+
|
24
|
+
gemspec :path => "../"
|
@@ -99,11 +99,13 @@ module Routemaster
|
|
99
99
|
private
|
100
100
|
|
101
101
|
def patch_post_or_put(type, url, body, headers)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
102
|
+
APIClientCircuit.new(url).call do
|
103
|
+
_wrapped_response _request(
|
104
|
+
type,
|
105
|
+
url: url,
|
106
|
+
body: body,
|
107
|
+
headers: headers)
|
108
|
+
end
|
107
109
|
end
|
108
110
|
|
109
111
|
def _assert_uri(url)
|
@@ -25,7 +25,6 @@ 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
|
-
|
29
28
|
def circuit
|
30
29
|
Circuitbox.circuit(@circuit_name, {
|
31
30
|
sleep_window: configuration_setting(@circuit_name, 'ROUTEMASTER_CIRCUIT_BREAKER_SLEEP_WINDOW', 60).to_i,
|
data/lib/routemaster/drain.rb
CHANGED
@@ -1,17 +1,19 @@
|
|
1
1
|
require 'core_ext/forwardable'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
if RUBY_VERSION == '2.4.0'
|
4
|
+
describe Forwardable do
|
5
|
+
class Foo
|
6
|
+
extend Forwardable
|
6
7
|
|
7
|
-
|
8
|
-
|
9
|
-
|
8
|
+
def initialize
|
9
|
+
@bar = :bar
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
-
|
12
|
+
def_delegator :@bar, :to_s, :qux
|
13
|
+
end
|
13
14
|
|
14
|
-
|
15
|
-
|
15
|
+
it 'expect delegation to work' do
|
16
|
+
expect(Foo.new.qux).to eq 'bar'
|
17
|
+
end
|
16
18
|
end
|
17
19
|
end
|
@@ -12,7 +12,10 @@ describe Routemaster::APIClientCircuit do
|
|
12
12
|
context "when enabled" do
|
13
13
|
before do
|
14
14
|
sb_req
|
15
|
-
|
15
|
+
allow(ENV).to receive(:fetch).and_call_original
|
16
|
+
allow(ENV)
|
17
|
+
.to receive(:fetch)
|
18
|
+
.with('ROUTEMASTER_ENABLE_API_CLIENT_CIRCUIT', 'NO').and_return('YES')
|
16
19
|
end
|
17
20
|
|
18
21
|
let(:url){ 'http://example.com/foobar' }
|
@@ -109,10 +109,38 @@ describe Routemaster::APIClient do
|
|
109
109
|
end
|
110
110
|
end
|
111
111
|
|
112
|
+
shared_examples 'a circuit breaker wrapped request' do
|
113
|
+
let(:fetcher) { described_class.new(retry_attempts: 0) }
|
114
|
+
let(:url) { 'https://circuit.example.com/circuit/132' }
|
115
|
+
let(:method) { :get }
|
116
|
+
|
117
|
+
before do
|
118
|
+
allow(ENV).to receive(:fetch).and_call_original
|
119
|
+
allow(ENV)
|
120
|
+
.to receive(:fetch)
|
121
|
+
.with('ROUTEMASTER_ENABLE_API_CLIENT_CIRCUIT', 'NO').and_return('YES')
|
122
|
+
allow(ENV)
|
123
|
+
.to receive(:fetch)
|
124
|
+
.with('ROUTEMASTER_CIRCUIT_BREAKER_ERROR_THRESHOLD', 50).and_return('1')
|
125
|
+
allow(ENV)
|
126
|
+
.to receive(:fetch)
|
127
|
+
.with('ROUTEMASTER_CIRCUIT_BREAKER_VOLUME_THRESHOLD', 50).and_return('1')
|
128
|
+
|
129
|
+
stub_request(method, url).to_timeout
|
130
|
+
end
|
131
|
+
|
132
|
+
it 'trips after the second request' do
|
133
|
+
5.times { expect { subject }.to raise_error StandardError }
|
134
|
+
expect(a_request(method, url)).to have_been_made.at_most_times(2)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
112
138
|
describe '#get' do
|
113
139
|
subject { fetcher.get(url, headers: headers) }
|
140
|
+
|
114
141
|
it_behaves_like 'a GET requester'
|
115
142
|
it_behaves_like 'a wrappable response'
|
143
|
+
it_behaves_like 'a circuit breaker wrapped request'
|
116
144
|
end
|
117
145
|
|
118
146
|
describe '#fget' do
|
@@ -183,6 +211,9 @@ describe Routemaster::APIClient do
|
|
183
211
|
end
|
184
212
|
|
185
213
|
it_behaves_like 'a wrappable response'
|
214
|
+
it_behaves_like 'a circuit breaker wrapped request' do
|
215
|
+
let(:method) { :post }
|
216
|
+
end
|
186
217
|
end
|
187
218
|
|
188
219
|
describe '#put' do
|
@@ -206,6 +237,9 @@ describe Routemaster::APIClient do
|
|
206
237
|
end
|
207
238
|
|
208
239
|
it_behaves_like 'a wrappable response'
|
240
|
+
it_behaves_like 'a circuit breaker wrapped request' do
|
241
|
+
let(:method) { :put }
|
242
|
+
end
|
209
243
|
end
|
210
244
|
|
211
245
|
context 'when request times out' do
|
@@ -282,6 +316,9 @@ describe Routemaster::APIClient do
|
|
282
316
|
end
|
283
317
|
|
284
318
|
it_behaves_like 'a wrappable response'
|
319
|
+
it_behaves_like 'a circuit breaker wrapped request' do
|
320
|
+
let(:method) { :patch }
|
321
|
+
end
|
285
322
|
end
|
286
323
|
|
287
324
|
context 'when request times out' 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.
|
4
|
+
version: 3.7.0
|
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: 2021-
|
11
|
+
date: 2021-12-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -164,7 +164,7 @@ dependencies:
|
|
164
164
|
- - '='
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 1.0.0
|
167
|
-
description:
|
167
|
+
description:
|
168
168
|
email:
|
169
169
|
- julien.letessier@gmail.com
|
170
170
|
executables: []
|
@@ -193,6 +193,7 @@ files:
|
|
193
193
|
- gemfiles/rails_3.gemfile
|
194
194
|
- gemfiles/rails_4.gemfile
|
195
195
|
- gemfiles/rails_5.gemfile
|
196
|
+
- gemfiles/rails_6.gemfile
|
196
197
|
- lib/core_ext/forwardable.rb
|
197
198
|
- lib/routemaster/api_client.rb
|
198
199
|
- lib/routemaster/api_client_circuit.rb
|
@@ -285,7 +286,7 @@ homepage: http://github.com/deliveroo/routemaster-drain
|
|
285
286
|
licenses:
|
286
287
|
- MIT
|
287
288
|
metadata: {}
|
288
|
-
post_install_message:
|
289
|
+
post_install_message:
|
289
290
|
rdoc_options: []
|
290
291
|
require_paths:
|
291
292
|
- lib
|
@@ -300,9 +301,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
301
|
- !ruby/object:Gem::Version
|
301
302
|
version: '0'
|
302
303
|
requirements: []
|
303
|
-
|
304
|
-
|
305
|
-
signing_key:
|
304
|
+
rubygems_version: 3.0.9
|
305
|
+
signing_key:
|
306
306
|
specification_version: 4
|
307
307
|
summary: Event receiver for the Routemaster bus
|
308
308
|
test_files:
|