Class: ArjAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/arj_adapter.rb

Overview

ActiveJob queue adapter for Arj.

If using Rails, configure via Rails::Application:

class MyApplication < Rails::Application
  config.active_job.queue_adapter = :arj
end

If not using Rails, configure via ActiveJob::Base:

ActiveJob::Base.queue_adapter = :arj

Instance Method Summary collapse

Instance Method Details

#enqueue(job) ⇒ ActiveJob::Base

Enqueue a job for immediate execution.

Parameters:

  • job (ActiveJob::Base)

    the job to enqueue

Returns:

  • (ActiveJob::Base)

    the enqueued job



22
23
24
25
26
# File 'lib/arj_adapter.rb', line 22

def enqueue(job)
  raise "expected ActiveJob::Base, found #{job.class}" unless job.is_a?(ActiveJob::Base)

  Arj::Persistence.enqueue(job)
end

#enqueue_at(job, timestamp) ⇒ ActiveJob::Base

Enqueue a job for execution at the specified time.

Parameters:

  • job (ActiveJob::Base)

    the job to enqueue

  • timestamp (Numeric, NilClass)

    optional number of seconds since Unix epoch at which to execute the job

Returns:

  • (ActiveJob::Base)

    the enqueued job



33
34
35
36
37
# File 'lib/arj_adapter.rb', line 33

def enqueue_at(job, timestamp)
  raise "expected ActiveJob::Base, found #{job.class}" unless job.is_a?(ActiveJob::Base)

  Arj::Persistence.enqueue(job, timestamp)
end