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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 266decce14cac0ea24835fd8854a8309f6ecf48b5478dcbdf285699213be5983
4
- data.tar.gz: 0c1de09f0a2d3299c1fd0f50cbc3e261ce4334d3eb0eec2dbfcf276f56d9b35e
3
+ metadata.gz: 730c804cff809632b9167826188f1f83860b31407439a36337459705c639afaf
4
+ data.tar.gz: 2fc56d9bf0be471f751c736f447f481f3ea81b89a39910013d4c51e010a09eeb
5
5
  SHA512:
6
- metadata.gz: bce30af416ed66d867c0deeb20658ca78418311ce8c9d42bb834743cd11ea7a735b253e5db0e7df882eeb75ca2ef4199c3ffa4f15c58f4e91bea18ab338ab15d
7
- data.tar.gz: 8cafb5c4db79a14c62a0a6c3a3bfa6c738ed38780bdda5041a88d47fa45b9458af44a21d4dc63f2c026089709e39a8ece18277b072484dab97b56068199fa1b7
6
+ metadata.gz: 865dcb84ce5050aceccb60d417033492d636377bf55b52f34c50271fdb7c6e6ceb1ec7acdbd47c25633b2629e9345470e8c79e3bd772ce58f673363b2bfeb24d
7
+ data.tar.gz: 7175c706b11ed3742cf359aae8cf1692640196a1b1407120cda0408c931d5b72ca2d190074496026214b2cdbef469b24bd33a37ddebf96a6f18955d65192dbca
data/LICENSE.txt CHANGED
@@ -1,4 +1,4 @@
1
- Copyright 2022 thomas morgan
1
+ Copyright 2022-2026 thomas morgan
2
2
 
3
3
  Permission is hereby granted, free of charge, to any person obtaining
4
4
  a copy of this software and associated documentation files (the
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 more specific type of `StandardError` and will discard it immediately, while still retrying all other types of
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
@@ -1,5 +1,8 @@
1
1
  require "bundler/setup"
2
2
 
3
+ APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
4
+ load "rails/tasks/engine.rake"
5
+
3
6
  require "bundler/gem_tasks"
4
7
  require "rake/testtask"
5
8
 
@@ -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
@@ -0,0 +1,10 @@
1
+ module RescueLikeAPro::MailDeliveryJob
2
+ extend ActiveSupport::Concern
3
+
4
+ def handle_exception_with_mailer_class(exception)
5
+ super
6
+ rescue Exception
7
+ rescue_like_a_pro $!
8
+ end
9
+
10
+ end
@@ -5,5 +5,9 @@ module RescueLikeAPro
5
5
  prepend RescueLikeAPro::ActiveJob
6
6
  end
7
7
 
8
+ configure do
9
+ ActionMailer::MailDeliveryJob.prepend RescueLikeAPro::MailDeliveryJob
10
+ end
11
+
8
12
  end
9
13
  end
@@ -1,3 +1,3 @@
1
1
  module RescueLikeAPro
2
- VERSION = "1.0.1"
2
+ VERSION = '1.3.0'
3
3
  end
@@ -1,7 +1,7 @@
1
1
  module RescueLikeAPro
2
2
  end
3
3
 
4
- %w(active_job version).each do |f|
4
+ %w(active_job mail_delivery_job version).each do |f|
5
5
  require "rescue_like_a_pro/#{f}"
6
6
  end
7
7
 
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.1
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: 2022-03-01 00:00:00.000000000 Z
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.2.22
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.