Class: ActiveJob::QueueAdapters::CloudtaskerAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/active_job/queue_adapters/cloudtasker_adapter.rb

Overview

Cloudtasker adapter for Active Job

To use Cloudtasker set the queue_adapter config to :cloudtasker.

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

Defined Under Namespace

Classes: JobWrapper

Constant Summary collapse

SERIALIZATION_FILTERED_KEYS =
[
  'executions', # Given by the worker at processing
  'provider_job_id', # Also given by the worker at processing
  'priority' # Not used
].freeze

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ Cloudtasker::CloudTask

Enqueues the given ActiveJob instance for execution

Parameters:

  • job (ActiveJob::Base)

    The ActiveJob instance

Returns:



26
27
28
# File 'lib/active_job/queue_adapters/cloudtasker_adapter.rb', line 26

def enqueue(job)
  build_worker(job).schedule
end

#enqueue_after_transaction_commit?Boolean

Determines if enqueuing will check and wait for an associated transaction completes before enqueuing

Returns:

  • (Boolean)

    True always as this is the default from QueueAdapters::AbstractAdapter



44
45
46
# File 'lib/active_job/queue_adapters/cloudtasker_adapter.rb', line 44

def enqueue_after_transaction_commit?
  true
end

#enqueue_at(job, precise_timestamp) ⇒ Cloudtasker::CloudTask

Enqueues the given ActiveJob instance for execution at a given time

Parameters:

  • job (ActiveJob::Base)

    The ActiveJob instance

  • precise_timestamp (Integer)

    The timestamp at which the job must be executed

Returns:



37
38
39
# 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