retriable 3.1.1 → 3.2.0
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 +5 -5
- data/.github/dependabot.yml +8 -0
- data/.github/workflows/main.yml +49 -0
- data/.hound.yml +2 -0
- data/.rspec +3 -0
- data/.rubocop.yml +11 -8
- data/CHANGELOG.md +88 -63
- data/CODE_OF_CONDUCT.md +10 -0
- data/Gemfile +4 -4
- data/README.md +144 -65
- data/Rakefile +9 -9
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/retriable/config.rb +6 -3
- data/lib/retriable/core_ext/kernel.rb +2 -0
- data/lib/retriable/exponential_backoff.rb +2 -1
- data/lib/retriable/version.rb +3 -1
- data/lib/retriable.rb +9 -4
- data/retriable.gemspec +7 -16
- data/sig/retriable.rbs +4 -0
- data/spec/config_spec.rb +37 -39
- data/spec/exponential_backoff_spec.rb +23 -44
- data/spec/retriable_spec.rb +203 -342
- data/spec/spec_helper.rb +9 -9
- data/spec/support/exceptions.rb +5 -0
- metadata +23 -59
- data/.travis.yml +0 -29
- data/Guardfile +0 -8
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
|
-
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 744d79bd8be89939c6d24deaf7430841d167f62a6eeb98259ea30c8af24c8018
|
|
4
|
+
data.tar.gz: 68a1900cef5b7d8455786a681660bbe3ab779c1ef9cafb274634c48b234131dc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 931cbd73e3d88e47384c1a34faf3deb71a2a87f4ab9dd21a967fb73f1a0a364e7c1b8cd0794dd71821d84a7968d739195561d71bf020bbc27af9af2e26599c1d
|
|
7
|
+
data.tar.gz: 55e596d2efb08d3cfc4aa2eb88f0db4b51589ae48b3d2ed9af6cc41e2f06ef91085b646f185818dd22474cd60c5ac91ea651fbfb9d08cf63a9e43a21867a3f91
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [master]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [master]
|
|
8
|
+
types: [opened, synchronize, reopened]
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
ci:
|
|
12
|
+
# The type of runner that the job will run on
|
|
13
|
+
runs-on: ${{ matrix.os }}
|
|
14
|
+
strategy:
|
|
15
|
+
matrix:
|
|
16
|
+
os: [ubuntu-24.04]
|
|
17
|
+
ruby:
|
|
18
|
+
[
|
|
19
|
+
"2.3",
|
|
20
|
+
"2.4",
|
|
21
|
+
"2.5",
|
|
22
|
+
"2.6",
|
|
23
|
+
"2.7",
|
|
24
|
+
"3.0",
|
|
25
|
+
"3.1",
|
|
26
|
+
"3.2",
|
|
27
|
+
"3.3",
|
|
28
|
+
"3.4",
|
|
29
|
+
"4.0",
|
|
30
|
+
jruby,
|
|
31
|
+
]
|
|
32
|
+
env:
|
|
33
|
+
CC_TEST_REPORTER_ID: 20a1139ef1830b4f813a10a03d90e8aa179b5226f75e75c5a949b25756ebf558
|
|
34
|
+
|
|
35
|
+
steps:
|
|
36
|
+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
|
|
37
|
+
- uses: actions/checkout@v6
|
|
38
|
+
|
|
39
|
+
- name: Setup ruby
|
|
40
|
+
uses: ruby/setup-ruby@v1
|
|
41
|
+
with:
|
|
42
|
+
ruby-version: ${{ matrix.ruby }}
|
|
43
|
+
bundler-cache: true
|
|
44
|
+
|
|
45
|
+
- name: ruby version
|
|
46
|
+
run: ruby -v
|
|
47
|
+
|
|
48
|
+
- name: Run rspec
|
|
49
|
+
run: bundle exec rspec
|
data/.hound.yml
ADDED
data/.rspec
ADDED
data/.rubocop.yml
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
Style/StringLiterals:
|
|
2
2
|
EnforcedStyle: double_quotes
|
|
3
3
|
|
|
4
|
+
Style/StringLiteralsInInterpolation:
|
|
5
|
+
EnforcedStyle: double_quotes
|
|
6
|
+
|
|
4
7
|
Style/Documentation:
|
|
5
8
|
Enabled: false
|
|
6
9
|
|
|
7
10
|
Style/TrailingCommaInArguments:
|
|
8
11
|
EnforcedStyleForMultiline: comma
|
|
9
12
|
|
|
10
|
-
|
|
11
|
-
EnforcedStyleForMultiline: comma
|
|
12
|
-
|
|
13
|
-
Style/InheritException:
|
|
13
|
+
Lint/InheritException:
|
|
14
14
|
Enabled: false
|
|
15
15
|
|
|
16
|
-
|
|
16
|
+
Layout/FirstArrayElementIndentation:
|
|
17
17
|
Enabled: false
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
Layout/FirstHashElementIndentation:
|
|
20
20
|
Enabled: false
|
|
21
21
|
|
|
22
22
|
Style/NegatedIf:
|
|
@@ -28,8 +28,8 @@ Metrics/ClassLength:
|
|
|
28
28
|
Metrics/ModuleLength:
|
|
29
29
|
Enabled: false
|
|
30
30
|
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
Layout/LineLength:
|
|
32
|
+
Max: 120
|
|
33
33
|
|
|
34
34
|
Metrics/MethodLength:
|
|
35
35
|
Enabled: false
|
|
@@ -39,3 +39,6 @@ Metrics/BlockLength:
|
|
|
39
39
|
|
|
40
40
|
Metrics/AbcSize:
|
|
41
41
|
Enabled: false
|
|
42
|
+
|
|
43
|
+
Style/TrailingCommaInArrayLiteral:
|
|
44
|
+
Enabled: false
|
data/CHANGELOG.md
CHANGED
|
@@ -1,116 +1,141 @@
|
|
|
1
|
-
|
|
1
|
+
# HEAD
|
|
2
|
+
|
|
3
|
+
## 3.2.0
|
|
4
|
+
|
|
5
|
+
- Require ruby 2.3+.
|
|
6
|
+
- Fix: Ensure `tries` value is overridden by `intervals` parameter if both are provided and add a test for this. This is always what the README stated but the code didn't actually do it.
|
|
7
|
+
- Fix: Some rubocop offenses.
|
|
8
|
+
|
|
9
|
+
## 3.1.2
|
|
10
|
+
|
|
11
|
+
- Replace `minitest` gem with `rspec`
|
|
12
|
+
- Fancier README
|
|
13
|
+
- Remove unnecessary short circuit in `randomize` method
|
|
2
14
|
|
|
3
15
|
## 3.1.1
|
|
4
16
|
|
|
5
|
-
|
|
6
|
-
|
|
17
|
+
- Fix typo in contexts exception message.
|
|
18
|
+
- Fix updating the version in the library.
|
|
7
19
|
|
|
8
20
|
## 3.1.0
|
|
9
21
|
|
|
10
|
-
|
|
22
|
+
- Added [contexts feature](https://github.com/kamui/retriable#contexts). Thanks to @apurvis.
|
|
11
23
|
|
|
12
24
|
## 3.0.2
|
|
13
25
|
|
|
14
|
-
|
|
26
|
+
- Add configuration and options validation.
|
|
15
27
|
|
|
16
28
|
## 3.0.1
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
29
|
+
|
|
30
|
+
- Add `rubocop` linter to enforce coding styles for this library. Also, fix rule violations.
|
|
31
|
+
- Removed `attr_reader :config` that caused a warning. @bruno-
|
|
32
|
+
- Clean up Rakefile testing cruft. @bruno-
|
|
33
|
+
- Use `.any?` in the `:on` hash processing. @apurvis
|
|
21
34
|
|
|
22
35
|
## 3.0.0
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
36
|
+
|
|
37
|
+
- Require ruby 2.0+.
|
|
38
|
+
- Breaking Change: `on` with a `Hash` value now matches subclassed exceptions. Thanks @apurvis!
|
|
39
|
+
- Remove `awesome_print` from development environment.
|
|
26
40
|
|
|
27
41
|
## 2.1.0
|
|
28
42
|
|
|
29
|
-
|
|
30
|
-
|
|
43
|
+
- Fix bug #17 due to confusing the initial try as a retry.
|
|
44
|
+
- Switch to `Minitest` 5.6 expect syntax.
|
|
31
45
|
|
|
32
46
|
## 2.0.2
|
|
33
47
|
|
|
34
|
-
|
|
48
|
+
- Change required_ruby_version in gemspec to >= 1.9.3.
|
|
35
49
|
|
|
36
50
|
## 2.0.1
|
|
37
51
|
|
|
38
|
-
|
|
52
|
+
- Add support for ruby 1.9.3.
|
|
39
53
|
|
|
40
54
|
## 2.0.0
|
|
41
55
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
56
|
+
- Require ruby 2.0+.
|
|
57
|
+
- Time intervals default to randomized exponential backoff instead of fixed time intervals. The delay between retries grows with every attempt and there's a randomization factor added to each attempt.
|
|
58
|
+
- `base_interval`, `max_interval`, `rand_factor`, and `multiplier` are new arguments that are used to generate randomized exponential back off time intervals.
|
|
59
|
+
- `interval` argument removed.
|
|
60
|
+
- Accept `intervals` array argument to provide your own custom intervals.
|
|
61
|
+
- Allow configurable defaults via `Retriable#configure` block.
|
|
62
|
+
- Add ability for `:on` argument to accept a `Hash` where the keys are exception types and the values are a single or array of `Regexp` pattern(s) to match against exception messages for retrial.
|
|
63
|
+
- Raise, not return, on max elapsed time.
|
|
64
|
+
- Check for elapsed time after next interval is calculated and it goes over the max elapsed time.
|
|
65
|
+
- Support early termination via `max_elapsed_time` argument.
|
|
52
66
|
|
|
53
67
|
## 2.0.0.beta5
|
|
54
|
-
|
|
68
|
+
|
|
69
|
+
- Change `:max_tries` back to `:tries`.
|
|
55
70
|
|
|
56
71
|
## 2.0.0.beta4
|
|
57
|
-
|
|
58
|
-
|
|
72
|
+
|
|
73
|
+
- Change #retry back to #retriable. Didn't like the idea of defining a method that is also a reserved word.
|
|
74
|
+
- Add ability for `:on` argument to accept a `Hash` where the keys are exception types and the values are a single or array of `Regexp` pattern(s) to match against exception messages for retrial.
|
|
59
75
|
|
|
60
76
|
## 2.0.0.beta3
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
77
|
+
|
|
78
|
+
- Accept `intervals` array argument to provide your own custom intervals.
|
|
79
|
+
- Refactor the exponential backoff code into it's own class.
|
|
80
|
+
- Add specs for exponential backoff, randomization, and config.
|
|
64
81
|
|
|
65
82
|
## 2.0.0.beta2
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
83
|
+
|
|
84
|
+
- Raise, not return, on max elapsed time.
|
|
85
|
+
- Check for elapsed time after next interval is calculated and it goes over the max elapsed time.
|
|
86
|
+
- Add specs for `max_elapsed_time` and `max_interval`.
|
|
69
87
|
|
|
70
88
|
## 2.0.0.beta1
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
89
|
+
|
|
90
|
+
- Require ruby 2.0+.
|
|
91
|
+
- Default to random exponential backoff, removes the `interval` option. Exponential backoff is configurable via arguments.
|
|
92
|
+
- Allow configurable defaults via `Retriable#configure` block.
|
|
93
|
+
- Change `Retriable.retriable` to `Retriable.retry`.
|
|
94
|
+
- Support early termination via `max_elapsed_time` argument.
|
|
76
95
|
|
|
77
96
|
## 1.4.1
|
|
78
|
-
|
|
97
|
+
|
|
98
|
+
- Fixes non kernel mode bug. Remove DSL class, move `#retriable` into Retriable module. Thanks @mkrogemann.
|
|
79
99
|
|
|
80
100
|
## 1.4.0
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
101
|
+
|
|
102
|
+
- By default, retriable doesn't monkey patch `Kernel`. If you want this functionality,
|
|
103
|
+
you can `require 'retriable/core_ext/kernel'.
|
|
104
|
+
- Upgrade minitest to 5.x.
|
|
105
|
+
- Refactor the DSL into it's own class.
|
|
85
106
|
|
|
86
107
|
## 1.3.3.1
|
|
87
|
-
|
|
108
|
+
|
|
109
|
+
- Allow sleep parameter to be a proc/lambda to allow for exponential backoff.
|
|
88
110
|
|
|
89
111
|
## 1.3.3
|
|
90
|
-
|
|
112
|
+
|
|
113
|
+
- sleep after executing the retry block, so there's no wait on the first call (molfar)
|
|
91
114
|
|
|
92
115
|
## 1.3.2
|
|
93
|
-
|
|
94
|
-
|
|
116
|
+
|
|
117
|
+
- Clean up option defaults.
|
|
118
|
+
- By default, rescue StandardError and Timeout::Error instead of [Exception](http://www.mikeperham.com/2012/03/03/the-perils-of-rescue-exception).
|
|
95
119
|
|
|
96
120
|
## 1.3.1
|
|
97
|
-
|
|
98
|
-
|
|
121
|
+
|
|
122
|
+
- Add `rake` dependency for travis-ci.
|
|
123
|
+
- Update gemspec summary and description.
|
|
99
124
|
|
|
100
125
|
## 1.3.0
|
|
101
126
|
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
127
|
+
- Rewrote a lot of the code with inspiration from [attempt](https://rubygems.org/gems/attempt).
|
|
128
|
+
- Add timeout option to the code block.
|
|
129
|
+
- Include in Kernel by default, but allow require 'retriable/no_kernel' to load a non kernel version.
|
|
130
|
+
- Renamed `:times` option to `:tries`.
|
|
131
|
+
- Renamed `:sleep` option to `:interval`.
|
|
132
|
+
- Renamed `:then` option to `:on_retry`.
|
|
133
|
+
- Removed other callbacks, you can wrap retriable in a begin/rescue/else/ensure block if you need that functionality. It avoids the need to define multiple Procs and makes the code more readable.
|
|
134
|
+
- Rewrote most of the README
|
|
110
135
|
|
|
111
136
|
## 1.2.0
|
|
112
137
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
138
|
+
- Forked the retryable-rb repo.
|
|
139
|
+
- Extend the Kernel module with the retriable method so you can use it anywhere without having to include it in every class.
|
|
140
|
+
- Update gemspec, Gemfile, and Raketask.
|
|
141
|
+
- Remove echoe dependency.
|
data/CODE_OF_CONDUCT.md
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
# Code of Conduct
|
|
2
|
+
|
|
3
|
+
"retriable" follows [The Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct) in all "collaborative space", which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.):
|
|
4
|
+
|
|
5
|
+
* Participants will be tolerant of opposing views.
|
|
6
|
+
* Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
|
|
7
|
+
* When interpreting the words and actions of others, participants should always assume good intentions.
|
|
8
|
+
* Behaviour which can be reasonably considered harassment will not be tolerated.
|
|
9
|
+
|
|
10
|
+
If you have any concerns about behaviour within this project, please contact us at ["jack@jackchu.com"](mailto:"jack@jackchu.com").
|
data/Gemfile
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
1
3
|
source "https://rubygems.org"
|
|
2
4
|
|
|
3
|
-
# Specify your gem's dependencies in retriable.gemspec
|
|
4
5
|
gemspec
|
|
5
6
|
|
|
6
7
|
group :test do
|
|
7
|
-
|
|
8
|
-
gem "codeclimate-test-reporter", require: false
|
|
9
|
-
gem "minitest-focus"
|
|
8
|
+
gem "rspec", "~> 3.0"
|
|
10
9
|
gem "simplecov", require: false
|
|
11
10
|
end
|
|
12
11
|
|
|
@@ -16,4 +15,5 @@ end
|
|
|
16
15
|
|
|
17
16
|
group :development, :test do
|
|
18
17
|
gem "pry"
|
|
18
|
+
gem "rake", "~> 13.0"
|
|
19
19
|
end
|