Class: ActiveJob::QueueAdapters::DelayedJobAdapter
- Inherits:
-
AbstractAdapter
- Object
- AbstractAdapter
- ActiveJob::QueueAdapters::DelayedJobAdapter
- Defined in:
- lib/active_job/queue_adapters/delayed_job_adapter.rb
Overview
Delayed Job adapter for Active Job
Delayed::Job (or DJ) encapsulates the common pattern of asynchronously executing longer tasks in the background. Although DJ can have many storage backends, one of the most used is based on Active Record. Read more about Delayed Job here.
To use Delayed Job, set the queue_adapter config to :delayed_job
.
Rails.application.config.active_job.queue_adapter = :delayed_job
Defined Under Namespace
Classes: JobWrapper
Instance Method Summary collapse
-
#enqueue(job) ⇒ Object
:nodoc:.
-
#enqueue_after_transaction_commit? ⇒ Boolean
:nodoc:.
-
#enqueue_at(job, timestamp) ⇒ Object
:nodoc:.
-
#initialize(enqueue_after_transaction_commit: false) ⇒ DelayedJobAdapter
constructor
A new instance of DelayedJobAdapter.
Constructor Details
#initialize(enqueue_after_transaction_commit: false) ⇒ DelayedJobAdapter
Returns a new instance of DelayedJobAdapter.
19 20 21 |
# File 'lib/active_job/queue_adapters/delayed_job_adapter.rb', line 19 def initialize(enqueue_after_transaction_commit: false) @enqueue_after_transaction_commit = enqueue_after_transaction_commit end |
Instance Method Details
#enqueue(job) ⇒ Object
:nodoc:
27 28 29 30 31 |
# File 'lib/active_job/queue_adapters/delayed_job_adapter.rb', line 27 def enqueue(job) # :nodoc: delayed_job = Delayed::Job.enqueue(JobWrapper.new(job.serialize), queue: job.queue_name, priority: job.priority) job.provider_job_id = delayed_job.id delayed_job end |
#enqueue_after_transaction_commit? ⇒ Boolean
:nodoc:
23 24 25 |
# File 'lib/active_job/queue_adapters/delayed_job_adapter.rb', line 23 def enqueue_after_transaction_commit? # :nodoc: @enqueue_after_transaction_commit end |
#enqueue_at(job, timestamp) ⇒ Object
:nodoc:
33 34 35 36 37 |
# File 'lib/active_job/queue_adapters/delayed_job_adapter.rb', line 33 def enqueue_at(job, ) # :nodoc: delayed_job = Delayed::Job.enqueue(JobWrapper.new(job.serialize), queue: job.queue_name, priority: job.priority, run_at: Time.at()) job.provider_job_id = delayed_job.id delayed_job end |