lhc 10.4.1 → 10.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/lhc/interceptors/throttle.rb +1 -1
- data/lib/lhc/version.rb +1 -1
- data/spec/interceptors/throttle/main_spec.rb +9 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e1d081bbe01eadc3a60d41068a65bb5b5f5e8d8d44547e8c076b8e0e5f72307d
|
4
|
+
data.tar.gz: e0c41de69f16e1146aa28227a67cebd278a6f203439bdd737aff1d8247522d2f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cfaafff18eea78de74559bc8d866be1d9bcc3666d69bd0ee9ed4eefc8da80b9a962a32e134dc1603299481ab1768f0f44f89b0154652ba2764faa9a08eb29e96
|
7
|
+
data.tar.gz: 74f4d0d051992fe02bdb31bafa8291b002466981430ad118b89fab189334ff6824864ead2021f86a0c967d7097e3809e75d1ad69e3e83d0f423099929e3b452a
|
@@ -33,7 +33,7 @@ class LHC::Throttle < LHC::Interceptor
|
|
33
33
|
def break_when_quota_reached!
|
34
34
|
options = request.options.dig(:throttle)
|
35
35
|
track = (self.class.track || {}).dig(options[:provider])
|
36
|
-
return
|
36
|
+
return if track.blank? || track[:remaining].blank? || track[:limit].blank?
|
37
37
|
# avoid floats by multiplying with 100
|
38
38
|
remaining = track[:remaining] * 100
|
39
39
|
limit = track[:limit]
|
data/lib/lhc/version.rb
CHANGED
@@ -77,5 +77,14 @@ describe LHC::Throttle do
|
|
77
77
|
it 'does not raise an exception' do
|
78
78
|
LHC.get('http://local.ch', options)
|
79
79
|
end
|
80
|
+
|
81
|
+
context 'no remaining tracked, but break enabled' do
|
82
|
+
let(:break_option) { '90%' }
|
83
|
+
|
84
|
+
it 'does not fail if a remaining was not tracked yet' do
|
85
|
+
LHC.get('http://local.ch', options)
|
86
|
+
LHC.get('http://local.ch', options)
|
87
|
+
end
|
88
|
+
end
|
80
89
|
end
|
81
90
|
end
|