Active Job 执行
提供立即执行作业的方法,并包装作业执行,以便使用 rescue_from 配置的异常得到处理。
命名空间
方法
包含模块
实例公共方法
perform(*) 链接
来源: 显示 | 在 GitHub 上
# File activejob/lib/active_job/execution.rb, line 60 def perform(*) fail NotImplementedError end
perform_now() 链接
立即执行作业。作业不会发送到排队适配器,而是通过阻塞其他执行直到完成来直接执行。perform_now
返回作业 perform
方法的值。
class MyJob < ActiveJob::Base
def perform
"Hello World!"
end
end
puts MyJob.new(*args).perform_now # => "Hello World!"
来源: 显示 | 在 GitHub 上
# File activejob/lib/active_job/execution.rb, line 45 def perform_now # Guard against jobs that were persisted before we started counting executions by zeroing out nil counters self.executions = (executions || 0) + 1 deserialize_arguments_if_needed _perform_job rescue Exception => exception handled = rescue_with_handler(exception) return handled if handled run_after_discard_procs(exception) raise end