Rename #perform_with_hooks to #execution

上级 ef4aff07
require 'active_job/queue_adapter'
require 'active_job/queue_name'
require 'active_job/enqueuing'
require 'active_job/performing'
require 'active_job/execution'
require 'active_job/logging'
require 'active_job/callbacks'
......@@ -11,7 +11,7 @@ class Base
extend QueueName
include Enqueuing
include Performing
include Execution
include Callbacks
include Logging
......
......@@ -2,14 +2,14 @@
require 'active_job/arguments'
module ActiveJob
module Performing
module Execution
extend ActiveSupport::Concern
included do
include ActiveSupport::Rescuable
end
def perform_with_hooks(*serialized_args)
def execute(*serialized_args)
self.arguments = Arguments.deserialize(serialized_args)
run_callbacks :perform do
......
......@@ -16,7 +16,7 @@ def enqueue_at(job, timestamp, *args)
class JobWrapper
class << self
def perform(job_name, *args)
job_name.constantize.new.perform_with_hooks *args
job_name.constantize.new.execute *args
end
end
end
......
......@@ -15,7 +15,7 @@ def enqueue_at(job, timestamp, *args)
class JobWrapper
def perform(job, *args)
job.new.perform_with_hooks *args
job.new.execute *args
end
end
end
......
......@@ -3,7 +3,7 @@ module QueueAdapters
class InlineAdapter
class << self
def enqueue(job, *args)
job.new.perform_with_hooks *args
job.new.execute *args
end
def enqueue_at(job, timestamp, *args)
......@@ -11,7 +11,7 @@ def enqueue_at(job, timestamp, *args)
begin
interval = Time.now.to_f - timestamp
sleep(interval) if interval > 0
job.new.perform_with_hooks *args
job.new.execute *args
rescue => e
ActiveJob::Base.logger.info "Error performing #{job}: #{e.message}"
end
......
......@@ -15,7 +15,7 @@ def enqueue_at(job, timestamp, *args)
class JobWrapper < Que::Job
def run(job, *args)
job.new.perform_with_hooks *args
job.new.execute *args
end
end
end
......
......@@ -15,7 +15,7 @@ def enqueue_at(job, timestamp, *args)
class JobWrapper
def self.perform(job, *args)
job.new.perform_with_hooks *args
job.new.execute *args
end
end
end
......
......@@ -19,7 +19,7 @@ def enqueue_at(job, timestamp, *args)
class JobWrapper
class << self
def perform(job_name, *args)
job_name.constantize.new.perform_with_hooks *args
job_name.constantize.new.execute *args
end
end
......
......@@ -26,7 +26,7 @@ class JobWrapper
include Sidekiq::Worker
def perform(job_name, *args)
job_name.constantize.new.perform_with_hooks *args
job_name.constantize.new.execute *args
end
end
end
......
......@@ -23,7 +23,7 @@ class JobWrapper
include Sneakers::Worker
def work(job, *args)
job.new.perform_with_hooks *args
job.new.execute *args
end
end
end
......
......@@ -17,7 +17,7 @@ class JobWrapper
include SuckerPunch::Job
def perform(job, *args)
job.new.perform_with_hooks *args
job.new.execute *args
end
end
end
......
......@@ -5,7 +5,7 @@
class CallbacksTest < ActiveSupport::TestCase
test 'perform callbacks' do
performed_callback_job = CallbackJob.new.tap { |j| j.perform_with_hooks }
performed_callback_job = CallbackJob.new.tap { |j| j.execute }
assert "CallbackJob ran before_perform".in? performed_callback_job.history
assert "CallbackJob ran after_perform".in? performed_callback_job.history
assert "CallbackJob ran around_perform_start".in? performed_callback_job.history
......
......@@ -10,7 +10,7 @@ class RescueTest < ActiveSupport::TestCase
test 'rescue perform exception with retry' do
job = RescueJob.new
job.perform_with_hooks("david")
job.execute("david")
assert_equal [ "rescued from StandardError", "performed beautifully" ], $BUFFER
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册