Delegate ActiveJob::Base#queue_adapter to class

This commit is contained in:
George Claghorn 2019-09-23 16:53:05 -04:00
parent 62cf3b278e
commit efbab35929
3 changed files with 7 additions and 4 deletions

View File

@ -52,9 +52,9 @@ module ActiveJob
run_callbacks :enqueue do
if scheduled_at
self.class.queue_adapter.enqueue_at self, scheduled_at
queue_adapter.enqueue_at self, scheduled_at
else
self.class.queue_adapter.enqueue self
queue_adapter.enqueue self
end
successfully_enqueued = true

View File

@ -18,7 +18,7 @@ module ActiveJob
private
def instrument(operation, payload = {}, &block)
ActiveSupport::Notifications.instrument \
"#{operation}.active_job", payload.merge(adapter: self.class.queue_adapter, job: self), &block
"#{operation}.active_job", payload.merge(adapter: queue_adapter, job: self), &block
end
end
end

View File

@ -10,7 +10,10 @@ module ActiveJob
included do
class_attribute :_queue_adapter_name, instance_accessor: false, instance_predicate: false
class_attribute :_queue_adapter, instance_accessor: false, instance_predicate: false
class_attribute :_queue_adapter, default: :async, instance_accessor: false, instance_predicate: false
delegate :queue_adapter, to: self
self.queue_adapter = :async
end