lhc 10.2.1 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +9 -0
- data/lib/lhc/interceptors/retry.rb +2 -2
- data/lib/lhc/version.rb +1 -1
- data/spec/interceptors/retry/main_spec.rb +17 -0
- metadata +2 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a923e58a34351a5d61e64d0f3bcc7516bcbfc17d7f06d0ef6cc3af9531b91bcc
|
4
|
+
data.tar.gz: 96f10388992ef3687fa01a62ef0e99fc831f8fbe1ce15d8abc15e2eb39d78a30
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3bb29402da0b779d8f485274defb9481fc78f0566f18bbbe3b3235ce4b214e1d936255d2293a0a9f7fc6c9694ca04458ec5ee927f53296aabcce5cf955f87def
|
7
|
+
data.tar.gz: 352657bdbc5d76f595ea5af072c794c02ecf64641f0c2fbcb2932948731ff7c5b11d26f75b03b03a3244b4bd60eb0417169f8a43951d5a90549e0541cced337f
|
data/README.md
CHANGED
@@ -814,6 +814,15 @@ Consider, that all other interceptors will run for every single retry.
|
|
814
814
|
LHC::Retry.max = 3
|
815
815
|
```
|
816
816
|
|
817
|
+
##### Retry all requests
|
818
|
+
|
819
|
+
If you want to retry all requests made from your application, you just need to configure it globally:
|
820
|
+
|
821
|
+
```ruby
|
822
|
+
LHC::Retry.all = true
|
823
|
+
configuration.interceptors = [LHC::Retry]
|
824
|
+
```
|
825
|
+
|
817
826
|
#### Rollbar Interceptor
|
818
827
|
|
819
828
|
Forward errors to rollbar when exceptions occur during http requests.
|
@@ -4,7 +4,7 @@ class LHC::Retry < LHC::Interceptor
|
|
4
4
|
attr_accessor :retries, :current_retry
|
5
5
|
|
6
6
|
class << self
|
7
|
-
attr_accessor :max
|
7
|
+
attr_accessor :max, :all
|
8
8
|
end
|
9
9
|
|
10
10
|
def after_response
|
@@ -24,7 +24,7 @@ class LHC::Retry < LHC::Interceptor
|
|
24
24
|
|
25
25
|
def retry?(request)
|
26
26
|
return false if request.response.success?
|
27
|
-
return false
|
27
|
+
return false if !request.options.dig(:retry) && !LHC::Retry.all
|
28
28
|
request.options[:retries] < max(request)
|
29
29
|
end
|
30
30
|
|
data/lib/lhc/version.rb
CHANGED
@@ -41,4 +41,21 @@ describe LHC::Rollbar do
|
|
41
41
|
expect(request_stub).to have_been_requested.times(2)
|
42
42
|
end
|
43
43
|
end
|
44
|
+
|
45
|
+
context 'retry all' do
|
46
|
+
let(:max_retry_count) { 2 }
|
47
|
+
|
48
|
+
before do
|
49
|
+
expect(LHC::Retry).to receive(:max).at_least(:once).and_return(2)
|
50
|
+
expect(LHC::Retry).to receive(:all).at_least(:once).and_return(true)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'retries if configured globally' do
|
54
|
+
request_stub
|
55
|
+
response = LHC.get('http://local.ch')
|
56
|
+
expect(response.success?).to eq true
|
57
|
+
expect(response.code).to eq 200
|
58
|
+
expect(request_stub).to have_been_requested.times(3)
|
59
|
+
end
|
60
|
+
end
|
44
61
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.
|
4
|
+
version: 10.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhc/contributors
|
@@ -371,8 +371,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
371
371
|
version: '0'
|
372
372
|
requirements:
|
373
373
|
- Ruby >= 2.0.0
|
374
|
-
|
375
|
-
rubygems_version: 2.7.8
|
374
|
+
rubygems_version: 3.0.3
|
376
375
|
signing_key:
|
377
376
|
specification_version: 4
|
378
377
|
summary: Advanced HTTP Client for Ruby, fueled with interceptors
|