Active Job 執行
提供立即執行工作的函式,以及包覆工作執行,以便處理透過 rescue_from 設定的例外狀況。
命名空間
函式
包含的模組
實例公開函式
perform(*) 連結
Source: 顯示 | 在 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!"
Source: 顯示 | 在 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