exp_retry 0.0.12 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/Gemfile.lock +3 -3
- data/exp-retry.gemspec +3 -3
- data/lib/exp_retry.rb +7 -6
- data/spec/lib/exp_retry_spec.rb +1 -1
- metadata +4 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1b9f68fbf37337a6969aa2805df08deb6c10d8b859647a184f8033811c7de848
|
4
|
+
data.tar.gz: 2263954dcb6c37ad927476bd6a09bcbfeb6d8655c395fbf4e2a74076d7ab3399
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7737de46de8b280fe380813398f356dcd832c56620b1736f9501200c08c5d2aefe87a30ca96d1c272bd9685a98730ffb1c1f709da2eee4282b007c45a4c30033
|
7
|
+
data.tar.gz: 3d7d128dbff9ad2d8e239c0fa6cd7b98dba3c2d959d1668be8962faf022c86b9f20c7f4b4a8aee16941c3edb8e46e116d6a222b0d58883a072f3c02688047d37
|
data/.travis.yml
CHANGED
@@ -8,6 +8,8 @@ notifications:
|
|
8
8
|
email:
|
9
9
|
on_success: change
|
10
10
|
on_failure: always
|
11
|
+
before_install:
|
12
|
+
- gem install bundler -v '< 2'
|
11
13
|
before_script:
|
12
14
|
- curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
|
13
15
|
- chmod +x ./cc-test-reporter
|
data/Gemfile.lock
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
exp_retry (0.0.
|
4
|
+
exp_retry (0.0.14)
|
5
5
|
|
6
6
|
GEM
|
7
7
|
remote: https://rubygems.org/
|
8
8
|
specs:
|
9
9
|
diff-lcs (1.3)
|
10
10
|
docile (1.3.1)
|
11
|
-
json (2.1
|
12
|
-
rake (12.3.
|
11
|
+
json (2.3.1)
|
12
|
+
rake (12.3.3)
|
13
13
|
rspec (3.8.0)
|
14
14
|
rspec-core (~> 3.8.0)
|
15
15
|
rspec-expectations (~> 3.8.0)
|
data/exp-retry.gemspec
CHANGED
@@ -2,8 +2,8 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = 'exp_retry'
|
5
|
-
s.version = '0.0.
|
6
|
-
s.date = '
|
5
|
+
s.version = '0.0.14'
|
6
|
+
s.date = '2023-03-13'
|
7
7
|
s.summary = 'Exponential backoff retry'
|
8
8
|
s.description = 'A simple exponential backoff retry wrapper.'
|
9
9
|
s.homepage = 'http://rubygems.org/gems/exp_retry'
|
@@ -14,7 +14,7 @@ Gem::Specification.new do |s|
|
|
14
14
|
s.files = `git ls-files`.split("\n")
|
15
15
|
s.test_files = `git ls-files -- spec/*`.split("\n")
|
16
16
|
|
17
|
-
s.required_ruby_version = '
|
17
|
+
s.required_ruby_version = '>= 2.3'
|
18
18
|
|
19
19
|
s.add_development_dependency 'rake', '~> 12.2', '>= 12.2.1'
|
20
20
|
s.add_development_dependency 'rspec', '~> 3.7', '>= 3.7.0'
|
data/lib/exp_retry.rb
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
# Exponential backoff retry wrapper
|
4
4
|
class ExpRetry
|
5
5
|
attr_accessor :retries
|
6
|
-
attr_reader :exception
|
6
|
+
attr_reader :exception, :tried
|
7
7
|
|
8
8
|
def self.for(retries: 3, exception: StandardError, verbose: false)
|
9
9
|
new(retries: retries, exception: exception, verbose: verbose).call { yield }
|
@@ -11,6 +11,7 @@ class ExpRetry
|
|
11
11
|
|
12
12
|
def initialize(retries: 3, exception: StandardError, wait: 1000, verbose: false)
|
13
13
|
@retries = retries
|
14
|
+
@tried = 0
|
14
15
|
@exception = exception
|
15
16
|
@verbose = verbose
|
16
17
|
@wait = wait
|
@@ -26,14 +27,14 @@ class ExpRetry
|
|
26
27
|
private
|
27
28
|
|
28
29
|
def check(exception)
|
29
|
-
raise(exception)
|
30
|
+
raise(exception) if tried >= retries
|
30
31
|
|
31
|
-
|
32
|
+
increment
|
32
33
|
delay
|
33
34
|
end
|
34
35
|
|
35
|
-
def
|
36
|
-
@
|
36
|
+
def increment
|
37
|
+
@tried += 1
|
37
38
|
end
|
38
39
|
|
39
40
|
def delay
|
@@ -43,6 +44,6 @@ private
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def time
|
46
|
-
2**
|
47
|
+
2**tried * (@wait.to_f / 1000)
|
47
48
|
end
|
48
49
|
end
|
data/spec/lib/exp_retry_spec.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: exp_retry
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-03-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -100,7 +100,7 @@ require_paths:
|
|
100
100
|
- doc
|
101
101
|
required_ruby_version: !ruby/object:Gem::Requirement
|
102
102
|
requirements:
|
103
|
-
- - "
|
103
|
+
- - ">="
|
104
104
|
- !ruby/object:Gem::Version
|
105
105
|
version: '2.3'
|
106
106
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
@@ -109,8 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '0'
|
111
111
|
requirements: []
|
112
|
-
|
113
|
-
rubygems_version: 2.7.6
|
112
|
+
rubygems_version: 3.1.6
|
114
113
|
signing_key:
|
115
114
|
specification_version: 4
|
116
115
|
summary: Exponential backoff retry
|