lhc 10.5.0 → 10.5.1
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 +14 -0
- data/lib/lhc/interceptors/retry.rb +1 -0
- data/lib/lhc/version.rb +1 -1
- data/spec/interceptors/retry/main_spec.rb +13 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b0317c2927977e904543c2d6f64b70324e6b94634ffce6ff1752cbaddd2acf2a
|
4
|
+
data.tar.gz: 19883b07caef846a43108601e931102348933abc4191af2c506d60496b86ec2e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6668ebf6f02d6cd4b9e49ff9f5fd22985dff77f7ae451b2062c1a65b93f32c1f8e3efabc981c0ce98b183e4f8435a8330dd274452cb5807444ce9da432e05377
|
7
|
+
data.tar.gz: ba098ab293a43a2035e79af76630d5a0fb5c867e73f5f0da7886fac697feeda98eed0c838bb8a3c72a83e577324f0e7b668f7dfb18b4b16bb0da5bd0d34cb27c
|
data/README.md
CHANGED
@@ -815,6 +815,20 @@ If you want to retry all requests made from your application, you just need to c
|
|
815
815
|
configuration.interceptors = [LHC::Retry]
|
816
816
|
```
|
817
817
|
|
818
|
+
##### Do not retry certain response codes
|
819
|
+
|
820
|
+
If you do not want to retry based on certain response codes, use retry in combination with explicit `ignore_errors`:
|
821
|
+
|
822
|
+
```ruby
|
823
|
+
LHC.get('http://local.ch', ignore_errors: [LHC::NotFound], retry: { max: 1 })
|
824
|
+
```
|
825
|
+
|
826
|
+
Or if you use `LHC::Retry.all`:
|
827
|
+
|
828
|
+
```ruby
|
829
|
+
LHC.get('http://local.ch', ignore_errors: [LHC::NotFound])
|
830
|
+
```
|
831
|
+
|
818
832
|
#### Rollbar Interceptor
|
819
833
|
|
820
834
|
Forward errors to rollbar when exceptions occur during http requests.
|
@@ -24,6 +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 if request.error_ignored?
|
27
28
|
return false if !request.options.dig(:retry) && !LHC::Retry.all
|
28
29
|
request.options[:retries] < max(request)
|
29
30
|
end
|
data/lib/lhc/version.rb
CHANGED
@@ -7,6 +7,8 @@ describe LHC::Rollbar do
|
|
7
7
|
LHC.config.interceptors = [LHC::Retry]
|
8
8
|
end
|
9
9
|
|
10
|
+
let(:status) { 500 }
|
11
|
+
|
10
12
|
let(:request_stub) do
|
11
13
|
@retry_count = 0
|
12
14
|
stub_request(:get, 'http://local.ch').to_return do |_|
|
@@ -14,7 +16,7 @@ describe LHC::Rollbar do
|
|
14
16
|
{ status: 200 }
|
15
17
|
else
|
16
18
|
@retry_count += 1
|
17
|
-
{ status:
|
19
|
+
{ status: status }
|
18
20
|
end
|
19
21
|
end
|
20
22
|
end
|
@@ -58,4 +60,14 @@ describe LHC::Rollbar do
|
|
58
60
|
expect(request_stub).to have_been_requested.times(3)
|
59
61
|
end
|
60
62
|
end
|
63
|
+
|
64
|
+
context 'ignore error' do
|
65
|
+
let(:status) { 404 }
|
66
|
+
|
67
|
+
it 'does not retry if the error is explicitly ignored' do
|
68
|
+
request_stub
|
69
|
+
LHC.get('http://local.ch', retry: { max: 1 }, ignored_errors: [LHC::NotFound])
|
70
|
+
expect(request_stub).to have_been_requested.times(1)
|
71
|
+
end
|
72
|
+
end
|
61
73
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: lhc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 10.5.
|
4
|
+
version: 10.5.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://github.com/local-ch/lhc/contributors
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-08-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|