aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/exceptions.rb
diff options
context:
space:
mode:
authorbogdanvlviv <bogdanvlviv@gmail.com>2018-09-16 17:39:55 +0300
committerbogdanvlviv <bogdanvlviv@gmail.com>2018-09-16 17:46:24 +0300
commitb6b5a7ac524a8c22d9ca162e53d752141f974651 (patch)
tree1c9adf873cedfea3bfd361e2580ff48b5d704913 /activejob/lib/active_job/exceptions.rb
parentfa2001ace68767daa126c6aaf7b120ff021af07b (diff)
downloadrails-b6b5a7ac524a8c22d9ca162e53d752141f974651.tar.gz
rails-b6b5a7ac524a8c22d9ca162e53d752141f974651.tar.bz2
rails-b6b5a7ac524a8c22d9ca162e53d752141f974651.zip
`retry_job` should publish `enqueue_retry.active_job` notification
Also this commit removes `:wait` from payload of `retry_stopped.active_job`. Related to https://github.com/rails/rails/pull/33751#discussion_r214140008 Follow up #33751 /cc @kaspth, @rafaelfranca
Diffstat (limited to 'activejob/lib/active_job/exceptions.rb')
-rw-r--r--activejob/lib/active_job/exceptions.rb28
1 files changed, 17 insertions, 11 deletions
diff --git a/activejob/lib/active_job/exceptions.rb b/activejob/lib/active_job/exceptions.rb
index d8384c81b6..bb25afbca6 100644
--- a/activejob/lib/active_job/exceptions.rb
+++ b/activejob/lib/active_job/exceptions.rb
@@ -46,18 +46,15 @@ module ActiveJob
# end
def retry_on(*exceptions, wait: 3.seconds, attempts: 5, queue: nil, priority: nil)
rescue_from(*exceptions) do |error|
- payload = {
- job: self,
- adapter: self.class.queue_adapter,
- error: error,
- wait: wait
- }
-
if executions < attempts
- ActiveSupport::Notifications.instrument("enqueue_retry.active_job", payload) do
- retry_job wait: determine_delay(wait), queue: queue, priority: priority
- end
+ retry_job wait: determine_delay(wait), queue: queue, priority: priority, error: error
else
+ payload = {
+ job: self,
+ adapter: self.class.queue_adapter,
+ error: error
+ }
+
if block_given?
ActiveSupport::Notifications.instrument("retry_stopped.active_job", payload) do
yield self, error
@@ -127,7 +124,16 @@ module ActiveJob
# end
# end
def retry_job(options = {})
- enqueue options
+ payload = {
+ job: self,
+ adapter: self.class.queue_adapter,
+ error: options[:error],
+ wait: options[:wait]
+ }
+
+ ActiveSupport::Notifications.instrument("enqueue_retry.active_job", payload) do
+ enqueue options
+ end
end
private