class ActiveJob::QueueAdapters::CloudtaskerAdapter

Cloudtasker adapter for Active Job

To use Cloudtasker set the queue_adapter config to :cloudtasker.

Rails.application.config.active_job.queue_adapter = :cloudtasker

Constants

SERIALIZATION_FILTERED_KEYS

Public Instance Methods

enqueue(job) click to toggle source

Enqueues the given ActiveJob instance for execution

@param job [ActiveJob::Base] The ActiveJob instance

@return [Cloudtasker::CloudTask] The Google Task response

# File lib/active_job/queue_adapters/cloudtasker_adapter.rb, line 26
def enqueue(job)
  build_worker(job).schedule
end
enqueue_at(job, precise_timestamp) click to toggle source

Enqueues the given ActiveJob instance for execution at a given time

@param job [ActiveJob::Base] The ActiveJob instance @param precise_timestamp [Integer] The timestamp at which the job must be executed

@return [Cloudtasker::CloudTask] The Google Task response

# File lib/active_job/queue_adapters/cloudtasker_adapter.rb, line 37
def enqueue_at(job, precise_timestamp)
  build_worker(job).schedule(time_at: Time.at(precise_timestamp))
end

Private Instance Methods

build_worker(job) click to toggle source
# File lib/active_job/queue_adapters/cloudtasker_adapter.rb, line 43
def build_worker(job)
  job_serialization = job.serialize.except(*SERIALIZATION_FILTERED_KEYS)

  JobWrapper.new(
    job_id: job_serialization.delete('job_id'),
    job_queue: job_serialization.delete('queue_name'),
    job_args: [job_serialization]
  )
end