aboutsummaryrefslogtreecommitdiffstats
path: root/activejob/lib/active_job/enqueuing.rb
diff options
context:
space:
mode:
authorKir Shatrov <shatrov@me.com>2018-09-26 17:25:20 +0100
committerKir Shatrov <shatrov@me.com>2018-10-28 15:02:44 -0400
commitee9fc120242b83c64bf77af1b72082ac76319332 (patch)
tree7b9fef67646c221c85c71be236d8bd50ffa2c7e4 /activejob/lib/active_job/enqueuing.rb
parent3295e23755744b7f9426d752481bb928fb02a89e (diff)
downloadrails-ee9fc120242b83c64bf77af1b72082ac76319332.tar.gz
rails-ee9fc120242b83c64bf77af1b72082ac76319332.tar.bz2
rails-ee9fc120242b83c64bf77af1b72082ac76319332.zip
Make AJ::Base#enqueue return false if the job wasn't enqueued
Diffstat (limited to 'activejob/lib/active_job/enqueuing.rb')
-rw-r--r--activejob/lib/active_job/enqueuing.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/activejob/lib/active_job/enqueuing.rb b/activejob/lib/active_job/enqueuing.rb
index 53cb98fc71..5be5618390 100644
--- a/activejob/lib/active_job/enqueuing.rb
+++ b/activejob/lib/active_job/enqueuing.rb
@@ -46,14 +46,25 @@ module ActiveJob
self.scheduled_at = options[:wait_until].to_f if options[:wait_until]
self.queue_name = self.class.queue_name_from_part(options[:queue]) if options[:queue]
self.priority = options[:priority].to_i if options[:priority]
+ successfully_enqueued = false
run_callbacks :enqueue do
if scheduled_at
self.class.queue_adapter.enqueue_at self, scheduled_at
else
self.class.queue_adapter.enqueue self
end
+ successfully_enqueued = true
+ end
+ if successfully_enqueued
+ self
+ else
+ if self.class.return_false_on_aborted_enqueue
+ false
+ else
+ ActiveSupport::Deprecation.warn "this will return false, set config.active_job.return_false_on_aborted_enqueue = true to remove deprecation."
+ self
+ end
end
- self
end
end
end