exp_retry 0.0.12 → 0.0.13
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 +1 -1
- data/exp-retry.gemspec +2 -2
- data/lib/exp_retry.rb +7 -6
- data/spec/lib/exp_retry_spec.rb +1 -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: 5534510118f308e1d03b685d72f02678c08d79e55884b2be0f4424906389e3a0
|
4
|
+
data.tar.gz: 8719251b81b72bc9725a60ca7567db1794daea3a2914bd8556c75c73b1f36509
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81d1d14c9dd4c3ce441f6f1b243c72c7cfc413bc1679a0ad867d9a9c0eee79127462baeb738a36bd360a6598e05b764fe4da2a81af132ad8a084dfa5ae0645ca
|
7
|
+
data.tar.gz: 6a5fd391e10cab2341ba4fe3d7022303edefaac65901b41da36865e9e14364b8ba35be46add5cbb2881144a92924835748a9af436de5a2fc6ca78ab239f3636a
|
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
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 = '2019-
|
5
|
+
s.version = '0.0.13'
|
6
|
+
s.date = '2019-07-11'
|
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'
|
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.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Julian Fiander
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|