routemaster-drain 3.6.8 → 3.7.1
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 +51 -9
- data/CHANGELOG.md +18 -0
- data/Gemfile +1 -1
- data/gemfiles/rails_4.gemfile +1 -1
- data/gemfiles/rails_5.gemfile +1 -1
- data/gemfiles/rails_6.gemfile +24 -0
- data/lib/routemaster/api_client.rb +8 -7
- 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 +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5244ce30cabc9ab7a8f13fdf327af90c8a4d30647a6bbf7b2c6630e2fd12ac21
|
4
|
+
data.tar.gz: 82671161ef1be99d85dd6d837754ed881e42a3accd9c170d53e32a2593a104ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6153b90031a758fd8bb7fd7edb08667b03df8e2441019c2087add39e9cfdaa9f0e9185a00b578a76dbc4fd82f294a4a354af0464ee57f4022f6427935d364e6d
|
7
|
+
data.tar.gz: bd25a70ee7ef6f238820b6873eaedbdab70274026050b1b65943118500c8678a7c20c04cdd4f6ba0fec8d07894e885e40cc829d6ef909ad705c3d8e846ac78ce
|
data/.circleci/config.yml
CHANGED
@@ -3,10 +3,9 @@
|
|
3
3
|
|
4
4
|
version: 2
|
5
5
|
jobs:
|
6
|
-
|
7
6
|
build_2.5_rails_5:
|
8
7
|
docker:
|
9
|
-
- image: circleci/ruby:2.4
|
8
|
+
- image: circleci/ruby:2.7.4
|
10
9
|
- image: redis:3-alpine
|
11
10
|
steps:
|
12
11
|
- checkout
|
@@ -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
@@ -2,6 +2,24 @@
|
|
2
2
|
|
3
3
|
_A description of your awesome changes here!_
|
4
4
|
|
5
|
+
### 3.7.1
|
6
|
+
|
7
|
+
Features:
|
8
|
+
|
9
|
+
- Add ruby 3 compability
|
10
|
+
|
11
|
+
Bug fixes:
|
12
|
+
|
13
|
+
- Explictly set sidekiq gem version
|
14
|
+
- Update circleci base image
|
15
|
+
- Remove `require 'faraday/request/retry'` dependency since its deprecated in faraday `1.10.3`.
|
16
|
+
|
17
|
+
### 3.7.0
|
18
|
+
|
19
|
+
Features:
|
20
|
+
|
21
|
+
- Adds circuit breaker to PATCH PUT POST requests (#66)
|
22
|
+
|
5
23
|
### 3.6.8
|
6
24
|
|
7
25
|
Features:
|
data/Gemfile
CHANGED
@@ -15,7 +15,7 @@ gem 'dotenv', require: false
|
|
15
15
|
gem 'simplecov', require: false
|
16
16
|
gem 'codecov', require: false
|
17
17
|
gem 'resque', require: false
|
18
|
-
gem 'sidekiq',
|
18
|
+
gem 'sidekiq', '~> 5.2.10', require: false
|
19
19
|
|
20
20
|
gem 'guard-rspec', require: false
|
21
21
|
gem 'pry', require: false
|
data/gemfiles/rails_4.gemfile
CHANGED
@@ -11,7 +11,7 @@ gem "dotenv", :require => false
|
|
11
11
|
gem "simplecov", :require => false
|
12
12
|
gem "codecov", :require => false
|
13
13
|
gem "resque", :require => false
|
14
|
-
gem "sidekiq", :require => false
|
14
|
+
gem "sidekiq", '~> 5.2.10', :require => false
|
15
15
|
gem "guard-rspec", :require => false
|
16
16
|
gem "pry", :require => false
|
17
17
|
gem "byebug", :require => false
|
data/gemfiles/rails_5.gemfile
CHANGED
@@ -11,7 +11,7 @@ gem "dotenv", :require => false
|
|
11
11
|
gem "simplecov", :require => false
|
12
12
|
gem "codecov", :require => false
|
13
13
|
gem "resque", :require => false
|
14
|
-
gem "sidekiq", :require => false
|
14
|
+
gem "sidekiq", '~> 5.2.10', :require => false
|
15
15
|
gem "guard-rspec", :require => false
|
16
16
|
gem "pry", :require => false
|
17
17
|
gem "byebug", :require => false
|
@@ -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", '~> 5.2.10', :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 => "../"
|
@@ -22,7 +22,6 @@ require 'typhoeus/adapters/faraday'
|
|
22
22
|
# prevents Faraday's magic class loading pixie dust from tripping over itself in
|
23
23
|
# multithreaded use cases.
|
24
24
|
require 'uri'
|
25
|
-
require 'faraday/request/retry'
|
26
25
|
require 'faraday_middleware/request/encode_json'
|
27
26
|
require 'faraday_middleware/response/parse_json'
|
28
27
|
require 'faraday_middleware/response/mashify'
|
@@ -73,7 +72,7 @@ module Routemaster
|
|
73
72
|
# Same as {{get}}, except with
|
74
73
|
def fget(url, **options)
|
75
74
|
uri = _assert_uri(url)
|
76
|
-
Responses::ResponsePromise.new { get(uri, options) }
|
75
|
+
Responses::ResponsePromise.new { get(uri, **options) }
|
77
76
|
end
|
78
77
|
|
79
78
|
def patch(url, body: {}, headers: {})
|
@@ -99,11 +98,13 @@ module Routemaster
|
|
99
98
|
private
|
100
99
|
|
101
100
|
def patch_post_or_put(type, url, body, headers)
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
101
|
+
APIClientCircuit.new(url).call do
|
102
|
+
_wrapped_response _request(
|
103
|
+
type,
|
104
|
+
url: url,
|
105
|
+
body: body,
|
106
|
+
headers: headers)
|
107
|
+
end
|
107
108
|
end
|
108
109
|
|
109
110
|
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.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julien Letessier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -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
|
@@ -300,8 +301,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
300
301
|
- !ruby/object:Gem::Version
|
301
302
|
version: '0'
|
302
303
|
requirements: []
|
303
|
-
|
304
|
-
rubygems_version: 2.6.11
|
304
|
+
rubygems_version: 3.3.26
|
305
305
|
signing_key:
|
306
306
|
specification_version: 4
|
307
307
|
summary: Event receiver for the Routemaster bus
|