提交 5bdeb9bf 编写于 作者: M Matthew Draper

Use AS::Reloader to support reloading in ActiveJob

上级 185c93eb
* Enable class reloading prior to job dispatch, and ensure Active Record
connections are returned to the pool when jobs are run in separate threads.
*Matthew Draper*
* Tune the async adapter for low-footprint dev/test usage. Use a single
thread pool for all queues and limit to 0 to #CPU total threads, down from
2 to 10*#CPU per queue.
......
......@@ -17,6 +17,11 @@ module Callbacks
extend ActiveSupport::Concern
include ActiveSupport::Callbacks
class << self
include ActiveSupport::Callbacks
define_callbacks :execute
end
included do
define_callbacks :perform
define_callbacks :enqueue
......
......@@ -17,8 +17,10 @@ def perform_now(*args)
end
def execute(job_data) #:nodoc:
job = deserialize(job_data)
job.perform_now
ActiveJob::Callbacks.run_callbacks(:execute) do
job = deserialize(job_data)
job.perform_now
end
end
end
......
......@@ -19,5 +19,14 @@ class Railtie < Rails::Railtie # :nodoc:
end
end
initializer "active_job.set_reloader_hook" do |app|
ActiveSupport.on_load(:active_job) do
ActiveJob::Callbacks.singleton_class.set_callback(:execute, :around, prepend: true) do |_, inner|
app.reloader.wrap do
inner.call
end
end
end
end
end
end
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册