retry_it 0.1.1 → 0.1.2
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/.ruby-version +1 -0
- data/.travis.yml +8 -6
- data/Gemfile.lock +3 -3
- data/README.md +4 -4
- data/lib/retry_it.rb +7 -7
- data/lib/retry_it/version.rb +1 -1
- data/retry_it.gemspec +1 -1
- metadata +12 -11
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2aeaa2845e5b554886e4c3efa5ca1272ce027d86792ee88b2eba25b2e73c72e7
|
|
4
|
+
data.tar.gz: 6fa2b4ea9088f999c95ddcbaf888abac2c4f80da52f1dfbb5122fa3f9c85ae68
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: bb76612dfe19d442426820161726d6bd6deca0c36cc69260266ffed7cd663f30b0ec5228fa3c5cf6b0265889112ae1995882d11307b6ac70f4a636ce8b2bce93
|
|
7
|
+
data.tar.gz: 892bba7a756595292e936331bd9a07b85b7bcb1bee81b4a810d74c056306fa57eba248c627e8a1a574d771429b7c0012e76079b15154aecdf94a37dd1eb9c092
|
data/.ruby-version
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
2.5.5
|
data/.travis.yml
CHANGED
data/Gemfile.lock
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
PATH
|
|
2
2
|
remote: .
|
|
3
3
|
specs:
|
|
4
|
-
retry_it (0.1.
|
|
4
|
+
retry_it (0.1.2)
|
|
5
5
|
|
|
6
6
|
GEM
|
|
7
7
|
remote: https://rubygems.org/
|
|
@@ -13,10 +13,10 @@ PLATFORMS
|
|
|
13
13
|
ruby
|
|
14
14
|
|
|
15
15
|
DEPENDENCIES
|
|
16
|
-
bundler
|
|
16
|
+
bundler
|
|
17
17
|
minitest (~> 5.0)
|
|
18
18
|
rake (~> 10.0)
|
|
19
19
|
retry_it!
|
|
20
20
|
|
|
21
21
|
BUNDLED WITH
|
|
22
|
-
|
|
22
|
+
2.0.2
|
data/README.md
CHANGED
|
@@ -23,7 +23,7 @@ Or install it yourself as:
|
|
|
23
23
|
|
|
24
24
|
Include RetryIt in your class:
|
|
25
25
|
|
|
26
|
-
```
|
|
26
|
+
```ruby
|
|
27
27
|
class APIClient
|
|
28
28
|
include RetryIt
|
|
29
29
|
end
|
|
@@ -31,7 +31,7 @@ end
|
|
|
31
31
|
|
|
32
32
|
You can then call `retry_it` when running code that fails intermittently:
|
|
33
33
|
|
|
34
|
-
```
|
|
34
|
+
```ruby
|
|
35
35
|
class APIClient
|
|
36
36
|
include RetryIt
|
|
37
37
|
|
|
@@ -69,7 +69,7 @@ the last error it received.
|
|
|
69
69
|
|
|
70
70
|
Examples:
|
|
71
71
|
|
|
72
|
-
```
|
|
72
|
+
```ruby
|
|
73
73
|
# Retry only on HTTPErrors with code 504. All other errors will not trigger a
|
|
74
74
|
# retry.
|
|
75
75
|
retry_it(timeout: 60, errors: [HTTPError], should_retry_proc: Proc.new { |e| e.code == 504 }) do
|
|
@@ -93,7 +93,7 @@ end
|
|
|
93
93
|
|
|
94
94
|
Keep in mind that you can pass methods as parameters using `method`:
|
|
95
95
|
|
|
96
|
-
```
|
|
96
|
+
```ruby
|
|
97
97
|
class APIClient
|
|
98
98
|
include RetryIt
|
|
99
99
|
|
data/lib/retry_it.rb
CHANGED
|
@@ -16,16 +16,16 @@ module RetryIt
|
|
|
16
16
|
yield
|
|
17
17
|
rescue *errors => e
|
|
18
18
|
retries += 1
|
|
19
|
-
|
|
19
|
+
should_retry_proc_result = should_retry_proc.respond_to?(:call) ? should_retry_proc.call(e) : true
|
|
20
|
+
|
|
21
|
+
if retries < max_runs && should_retry_proc_result
|
|
20
22
|
if logger
|
|
21
23
|
logger.info "Error (#{e.class}), retrying ##{retries} of #{max_runs}. Sleeping for #{timeout}"
|
|
22
24
|
end
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
sleep timeout
|
|
28
|
-
end
|
|
25
|
+
|
|
26
|
+
on_error.call(e) if on_error && on_error.respond_to?(:call)
|
|
27
|
+
sleep timeout if timeout > 0
|
|
28
|
+
|
|
29
29
|
retry
|
|
30
30
|
else
|
|
31
31
|
raise
|
data/lib/retry_it/version.rb
CHANGED
data/retry_it.gemspec
CHANGED
|
@@ -23,7 +23,7 @@ Gem::Specification.new do |spec|
|
|
|
23
23
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
|
24
24
|
spec.require_paths = ["lib"]
|
|
25
25
|
|
|
26
|
-
spec.add_development_dependency "bundler"
|
|
26
|
+
spec.add_development_dependency "bundler"
|
|
27
27
|
spec.add_development_dependency "rake", "~> 10.0"
|
|
28
28
|
spec.add_development_dependency "minitest", "~> 5.0"
|
|
29
29
|
end
|
metadata
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: retry_it
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.2
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- rgould
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2020-06-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
|
16
16
|
requirements:
|
|
17
|
-
- - "
|
|
17
|
+
- - ">="
|
|
18
18
|
- !ruby/object:Gem::Version
|
|
19
|
-
version: '
|
|
19
|
+
version: '0'
|
|
20
20
|
type: :development
|
|
21
21
|
prerelease: false
|
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
|
23
23
|
requirements:
|
|
24
|
-
- - "
|
|
24
|
+
- - ">="
|
|
25
25
|
- !ruby/object:Gem::Version
|
|
26
|
-
version: '
|
|
26
|
+
version: '0'
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -61,6 +61,7 @@ extensions: []
|
|
|
61
61
|
extra_rdoc_files: []
|
|
62
62
|
files:
|
|
63
63
|
- ".gitignore"
|
|
64
|
+
- ".ruby-version"
|
|
64
65
|
- ".travis.yml"
|
|
65
66
|
- Gemfile
|
|
66
67
|
- Gemfile.lock
|
|
@@ -75,7 +76,7 @@ homepage: https://github.com/DaliaResearch/retry_it
|
|
|
75
76
|
licenses:
|
|
76
77
|
- MIT
|
|
77
78
|
metadata: {}
|
|
78
|
-
post_install_message:
|
|
79
|
+
post_install_message:
|
|
79
80
|
rdoc_options: []
|
|
80
81
|
require_paths:
|
|
81
82
|
- lib
|
|
@@ -90,9 +91,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
90
91
|
- !ruby/object:Gem::Version
|
|
91
92
|
version: '0'
|
|
92
93
|
requirements: []
|
|
93
|
-
rubyforge_project:
|
|
94
|
-
rubygems_version: 2.7.6
|
|
95
|
-
signing_key:
|
|
94
|
+
rubyforge_project:
|
|
95
|
+
rubygems_version: 2.7.6.2
|
|
96
|
+
signing_key:
|
|
96
97
|
specification_version: 4
|
|
97
98
|
summary: Easily retry code that fails intermittently
|
|
98
99
|
test_files: []
|