retryable 3.0.4 → 3.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +6 -0
- data/README.md +9 -6
- data/lib/retryable.rb +3 -1
- data/lib/retryable/version.rb +1 -1
- data/spec/retryable/configuration_spec.rb +16 -0
- data/spec/retryable_spec.rb +22 -7
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 4adf6498d39c3a76bb6c3ea4c2ef8bd479d620b65c969cc43c970ae1dc1e8dd7
|
4
|
+
data.tar.gz: d60ff44f63519d2df8a70ca8729e5db2cda03e2b9ba2bf9af42dae66df9f65d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 24fc7de390a5996451a2c9d0296811b031ce21e38a3c4374d4a002e3e12d6278c07f31a84dd86efcf9006fd2ff2f7ef40e40da791f2d98dedb56ee2b0c7b3006
|
7
|
+
data.tar.gz: '09360b246ca4c6868fc40807f1fc4978933f3aae138237efdb396e51e52a36fd2c8e1a44310365336cc9d43c08df62726d9d390739e3fdcce23640abdb0b2733'
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
## Retryable 3.0.5 ##
|
2
|
+
|
3
|
+
Instead of :infinite magic constant from now on you can just use Ruby's native infinity data type e.g. Float::INFINITY.
|
4
|
+
See https://github.com/nfedyashev/retryable/commit/16f60bb09560c9470266dca8cd47c934594a67c5
|
5
|
+
This version is backwards compatible with older versions, no changes needed in your code.
|
6
|
+
|
1
7
|
## Retryable 3.0.4 ##
|
2
8
|
|
3
9
|
Fixed typo in exception message given invalid :matching argument type https://github.com/nfedyashev/retryable/pull/29
|
data/README.md
CHANGED
@@ -50,9 +50,11 @@ end
|
|
50
50
|
|
51
51
|
Try the block forever.
|
52
52
|
```ruby
|
53
|
-
|
53
|
+
# For ruby versions prior to 1.9.2 use :infinite symbol instead
|
54
|
+
Retryable.retryable(tries: Float::INFINITY) do
|
54
55
|
# code here
|
55
56
|
end
|
57
|
+
|
56
58
|
```
|
57
59
|
|
58
60
|
Do something, retry up to four times for either `ArgumentError` or
|
@@ -261,11 +263,12 @@ versions:
|
|
261
263
|
|
262
264
|
* Ruby 1.9.3
|
263
265
|
* Ruby 2.0.0
|
264
|
-
* Ruby 2.1.
|
265
|
-
* Ruby 2.2.
|
266
|
-
* Ruby 2.3.
|
267
|
-
* Ruby 2.4.
|
268
|
-
* Ruby 2.5.
|
266
|
+
* Ruby 2.1.10
|
267
|
+
* Ruby 2.2.10
|
268
|
+
* Ruby 2.3.8
|
269
|
+
* Ruby 2.4.5
|
270
|
+
* Ruby 2.5.3
|
271
|
+
* Ruby 2.6.1
|
269
272
|
|
270
273
|
*NOTE: if you need `retryable` to be running on Ruby 1.8 use gem versions prior to 3.0.0 release*
|
271
274
|
|
data/lib/retryable.rb
CHANGED
@@ -75,7 +75,9 @@ module Retryable
|
|
75
75
|
rescue *on_exception => exception
|
76
76
|
raise unless configuration.enabled?
|
77
77
|
raise unless matches?(exception.message, matching)
|
78
|
-
|
78
|
+
|
79
|
+
infinite_retries = :infinite || tries.respond_to?(:infinite?) && tries.infinite?
|
80
|
+
raise if tries != infinite_retries && retries + 1 >= tries
|
79
81
|
|
80
82
|
# Interrupt Exception could be raised while sleeping
|
81
83
|
begin
|
data/lib/retryable/version.rb
CHANGED
@@ -21,6 +21,22 @@ RSpec.describe Retryable do
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
|
24
|
+
context 'when configured locally' do
|
25
|
+
it 'does not affect the original global config' do
|
26
|
+
new_sleep = 2
|
27
|
+
original_sleep = described_class.configuration.send(:sleep)
|
28
|
+
|
29
|
+
expect(original_sleep).not_to eq(new_sleep)
|
30
|
+
|
31
|
+
counter(tries: 2, sleep: new_sleep) do |tries, ex|
|
32
|
+
raise StandardError if tries < 1
|
33
|
+
end
|
34
|
+
|
35
|
+
actual = described_class.configuration.send(:sleep)
|
36
|
+
expect(actual).to eq(original_sleep)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
24
40
|
context 'when configured globally with custom sleep parameter' do
|
25
41
|
it 'passes retry count and exception on retry' do
|
26
42
|
expect(Kernel).to receive(:sleep).once.with(3)
|
data/spec/retryable_spec.rb
CHANGED
@@ -78,14 +78,29 @@ RSpec.describe Retryable do
|
|
78
78
|
expect(counter.count).to eq(3)
|
79
79
|
end
|
80
80
|
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
81
|
+
context 'infinite retries' do
|
82
|
+
example 'with magic constant' do
|
83
|
+
expect do
|
84
|
+
Timeout.timeout(3) do
|
85
|
+
counter(tries: :infinite, sleep: 0.1) { raise StandardError }
|
86
|
+
end
|
87
|
+
end.to raise_error Timeout::Error
|
88
|
+
|
89
|
+
expect(counter.count).to be > 10
|
90
|
+
end
|
87
91
|
|
88
|
-
|
92
|
+
example 'with native infinity data type' do
|
93
|
+
expect do
|
94
|
+
require 'bigdecimal'
|
95
|
+
|
96
|
+
tries = [Float::INFINITY, BigDecimal::INFINITY, BigDecimal("1.0") / BigDecimal("0.0")]
|
97
|
+
Timeout.timeout(3) do
|
98
|
+
counter(tries: tries.sample, sleep: 0.1) { raise StandardError }
|
99
|
+
end
|
100
|
+
end.to raise_error Timeout::Error
|
101
|
+
|
102
|
+
expect(counter.count).to be > 10
|
103
|
+
end
|
89
104
|
end
|
90
105
|
|
91
106
|
it 'executes exponential backoff scheme for :sleep option' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: retryable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nikita Fedyashev
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2019-
|
13
|
+
date: 2019-11-11 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -70,8 +70,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
70
70
|
- !ruby/object:Gem::Version
|
71
71
|
version: 1.3.6
|
72
72
|
requirements: []
|
73
|
-
|
74
|
-
rubygems_version: 2.4.5.2
|
73
|
+
rubygems_version: 3.0.3
|
75
74
|
signing_key:
|
76
75
|
specification_version: 4
|
77
76
|
summary: Retrying code blocks in Ruby
|