lhc 10.2.1 → 10.3.0

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: 5995d465230282a514f8578d41bd62ff6013550f15408e3ff174a087d8ce8247
4
- data.tar.gz: 574aaaa921e4f7ee9f724082d21ed2188fb8ae054645e0238a18838ad5fbf7c1
3
+ metadata.gz: a923e58a34351a5d61e64d0f3bcc7516bcbfc17d7f06d0ef6cc3af9531b91bcc
4
+ data.tar.gz: 96f10388992ef3687fa01a62ef0e99fc831f8fbe1ce15d8abc15e2eb39d78a30
5
5
  SHA512:
6
- metadata.gz: 4886f53416547af48f05145d1400cdd91da733eb7231e56d646232084295c6c927f2cde2c408ac9b058450964049aee2d62caf29c0096f5f36a4e6b307169fad
7
- data.tar.gz: e06fb5be41f70e2f6cdf7009c3fe574843b47638003625edb38f3e36e311744e9e297fc21c080d978284d63039e8b5849d0f78e7f5613e923c79127ba16e354c
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 unless request.options.dig(:retry)
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
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module LHC
4
- VERSION ||= '10.2.1'
4
+ VERSION ||= '10.3.0'
5
5
  end
@@ -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.2.1
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
- rubyforge_project:
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