class AsyncActiveJob::Adapter
Public Instance Methods
enqueue(active_job)
click to toggle source
@param active_job [ActiveJob::Base] the job to be enqueued from #perform_later
@return [AsyncActiveJob::Job]
# File lib/async_active_job/adapter.rb, line 7 def enqueue(active_job) enqueue_at(active_job, nil) end
enqueue_at(active_job, timestamp)
click to toggle source
@param active_job [ActiveJob::Base] the job to be enqueued from #perform_later
@param timestamp [Integer, nil] the epoch time to perform the job @return [AsyncActiveJob::Job]
# File lib/async_active_job/adapter.rb, line 14 def enqueue_at(active_job, timestamp) scheduled_at = timestamp ? Time.zone.at(timestamp) : nil opts = { active_job: active_job, scheduled_at: scheduled_at } ActiveSupport::Notifications.instrument('enqueue_job.async_active_job', opts) do |instrument_payload| async_active_job = AsyncActiveJob::Job.enqueue( JobWrapper.new(active_job.serialize), queue_name: active_job.queue_name || AsyncActiveJob.configuration.default_queue_name, priority: active_job.priority || AsyncActiveJob.configuration.default_priority, run_at: scheduled_at || Time.zone.now ) instrument_payload[:async_active_job] = async_active_job active_job.provider_job_id = async_active_job.id async_active_job end end