lhc 10.5.0 → 10.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3cf5537cde6885a7e37d2bb70d7b222e761804018d0aab94bd9249c68a40d3f7
4
- data.tar.gz: 1d501413fd820cffc020cc39eec04b4e775440abebdf61e030f8d6114b660922
3
+ metadata.gz: b0317c2927977e904543c2d6f64b70324e6b94634ffce6ff1752cbaddd2acf2a
4
+ data.tar.gz: 19883b07caef846a43108601e931102348933abc4191af2c506d60496b86ec2e
5
5
  SHA512:
6
- metadata.gz: 5fc4d1cb8b374931d4c53d295319e6f3c16657e0bde1dd7aa0799812bbc378390165f097b7c6627ced47f92d2ebe7459d5180745a4b00692875fbdfffda2c931
7
- data.tar.gz: d5d39be61013fe93e275d2725e7fc4cfec83f27646c36762a2c3fbe64d1c40aa9831f7274fb7a46a7ff1500244a19a8fe76b2887539cb0e2f435a438178ff21a
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHC
4
- VERSION ||= '10.5.0'
4
+ VERSION ||= '10.5.1'
5
5
  end
@@ -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: 500 }
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.0
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-07-23 00:00:00.000000000 Z
11
+ date: 2019-08-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport