rescue_like_a_pro 1.0.1 → 1.3.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 +4 -4
- data/LICENSE.txt +1 -1
- data/README.md +19 -2
- data/Rakefile +3 -0
- data/lib/rescue_like_a_pro/active_job.rb +1 -1
- data/lib/rescue_like_a_pro/mail_delivery_job.rb +10 -0
- data/lib/rescue_like_a_pro/railtie.rb +4 -0
- data/lib/rescue_like_a_pro/version.rb +1 -1
- data/lib/rescue_like_a_pro.rb +1 -1
- metadata +4 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 730c804cff809632b9167826188f1f83860b31407439a36337459705c639afaf
|
|
4
|
+
data.tar.gz: 2fc56d9bf0be471f751c736f447f481f3ea81b89a39910013d4c51e010a09eeb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 865dcb84ce5050aceccb60d417033492d636377bf55b52f34c50271fdb7c6e6ceb1ec7acdbd47c25633b2629e9345470e8c79e3bd772ce58f673363b2bfeb24d
|
|
7
|
+
data.tar.gz: 7175c706b11ed3742cf359aae8cf1692640196a1b1407120cda0408c931d5b72ca2d190074496026214b2cdbef469b24bd33a37ddebf96a6f18955d65192dbca
|
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
|
@@ -23,8 +23,7 @@ RescueLikeAPro rethinks ActiveJob's exception handling system by:
|
|
|
23
23
|
|
|
24
24
|
With ActiveJob's default exception handling, `DeserializationError`s will never be discarded by `SomeJob` because exceptions are processed from last to first. Since `DeserializationError` is a type of `StandardError`, `retry_on` will see it, reattempt 5 times, then trigger retries-exhausted--which in this case, without a block on `retry_on`, will bubble the error upward.
|
|
25
25
|
|
|
26
|
-
In contrast, RescueLikeAPro will recognize that `DeserializationError` is a
|
|
27
|
-
`StandardError`s.
|
|
26
|
+
In contrast, RescueLikeAPro will recognize that `DeserializationError` is a subclass of `StandardError` and will discard it immediately, while still retrying all other types of `StandardError`s.
|
|
28
27
|
|
|
29
28
|
Child classes may, of course, still redefine handling for an exception previously defined in a parent.
|
|
30
29
|
|
|
@@ -58,6 +57,12 @@ RescueLikeAPro rethinks ActiveJob's exception handling system by:
|
|
|
58
57
|
|
|
59
58
|
* Jitter is applied to all retries. In contrast, ActiveJob skips jitter when `:wait` is a Proc.
|
|
60
59
|
|
|
60
|
+
* ActionMailer::MailDeliveryJob is extended to allow for exception handlers, including retries, to be added to the job.
|
|
61
|
+
|
|
62
|
+
`ActionMailer::MailDeliveryJob` is the internal job used to deliver emails later with `SomeMailer.message.deliver_later`. By default, it only runs each Mailer's rescue_from handlers, bypassing any exception handlers (including retries) added to the job.
|
|
63
|
+
|
|
64
|
+
RescueLikeAPro changes this. Upon an exception, any rescue_from handlers on the Mailer will run first (using normal rescue_from rules). If no handler is found, or if the handler raises (or reraises) an exception, then the exception will be sent to the job's handlers.
|
|
65
|
+
|
|
61
66
|
|
|
62
67
|
### Example syntax
|
|
63
68
|
|
|
@@ -106,6 +111,7 @@ class ActiveJob::Base
|
|
|
106
111
|
# on_discard{ ... }
|
|
107
112
|
# on_retries_exhausted{ ... }
|
|
108
113
|
# etc
|
|
114
|
+
end
|
|
109
115
|
```
|
|
110
116
|
|
|
111
117
|
Otherwise, to just modify all of your app's jobs, add instructions to `app/jobs/application_job.rb`.
|
|
@@ -113,6 +119,17 @@ Otherwise, to just modify all of your app's jobs, add instructions to `app/jobs/
|
|
|
113
119
|
And of course, add any per-Job instructions directly to that job class.
|
|
114
120
|
|
|
115
121
|
|
|
122
|
+
### ActionMailer::MailDeliveryJob
|
|
123
|
+
|
|
124
|
+
MailDeliveryJob may warrant special attention. To make delayed mail deliveries retryable, add `retry_on` to either ActiveJob::Base or MailDeliveryJob.
|
|
125
|
+
|
|
126
|
+
For example, again in an initializer:
|
|
127
|
+
|
|
128
|
+
```ruby
|
|
129
|
+
ActionMailer::MailDeliveryJob.retry_on IOError, SystemCallError, Timeout::Error, wait: 1.minute, attempts: 5
|
|
130
|
+
```
|
|
131
|
+
|
|
132
|
+
|
|
116
133
|
## Installation
|
|
117
134
|
|
|
118
135
|
As usual, add RescueLikeAPro to your Gemfile:
|
data/Rakefile
CHANGED
|
@@ -86,7 +86,7 @@ module RescueLikeAPro::ActiveJob
|
|
|
86
86
|
|
|
87
87
|
def determine_delay(seconds_or_duration_or_algorithm:, executions:, jitter: nil)
|
|
88
88
|
case seconds_or_duration_or_algorithm
|
|
89
|
-
when :exponentially_longer
|
|
89
|
+
when :exponentially_longer, :polynomially_longer
|
|
90
90
|
delay = executions**4
|
|
91
91
|
delay_jitter = determine_jitter_for_delay(delay, jitter)
|
|
92
92
|
delay + delay_jitter + 2
|
data/lib/rescue_like_a_pro.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: rescue_like_a_pro
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.0
|
|
4
|
+
version: 1.3.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- thomas morgan
|
|
8
|
-
autorequire:
|
|
9
8
|
bindir: bin
|
|
10
9
|
cert_chain: []
|
|
11
|
-
date:
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
12
11
|
dependencies:
|
|
13
12
|
- !ruby/object:Gem::Dependency
|
|
14
13
|
name: activejob
|
|
@@ -80,6 +79,7 @@ files:
|
|
|
80
79
|
- Rakefile
|
|
81
80
|
- lib/rescue_like_a_pro.rb
|
|
82
81
|
- lib/rescue_like_a_pro/active_job.rb
|
|
82
|
+
- lib/rescue_like_a_pro/mail_delivery_job.rb
|
|
83
83
|
- lib/rescue_like_a_pro/railtie.rb
|
|
84
84
|
- lib/rescue_like_a_pro/version.rb
|
|
85
85
|
homepage: https://github.com/zarqman/rescue_like_a_pro
|
|
@@ -89,7 +89,6 @@ metadata:
|
|
|
89
89
|
homepage_uri: https://github.com/zarqman/rescue_like_a_pro
|
|
90
90
|
source_code_uri: https://github.com/zarqman/rescue_like_a_pro
|
|
91
91
|
changelog_uri: https://github.com/zarqman/rescue_like_a_pro/blob/master/CHANGELOG.md
|
|
92
|
-
post_install_message:
|
|
93
92
|
rdoc_options: []
|
|
94
93
|
require_paths:
|
|
95
94
|
- lib
|
|
@@ -104,8 +103,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
104
103
|
- !ruby/object:Gem::Version
|
|
105
104
|
version: '0'
|
|
106
105
|
requirements: []
|
|
107
|
-
rubygems_version: 3.
|
|
108
|
-
signing_key:
|
|
106
|
+
rubygems_version: 3.6.9
|
|
109
107
|
specification_version: 4
|
|
110
108
|
summary: Improve ActiveJob exception handling with inheritance, fallback handlers,
|
|
111
109
|
more jitter options, etc.
|