Sha256: 3cfc7131283b9211a8b1c55330cf4aae0fd5ca079fb90059977c810f45f76e5b

Contents?: true

Size: 1.16 KB

Versions: 48

Compression:

Stored size: 1.16 KB

Contents

require 'delayed_job'

module ActiveJob
  module QueueAdapters
    # == 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}[https://github.com/collectiveidea/delayed_job].
    #
    # To use Delayed Job, set the queue_adapter config to +:delayed_job+.
    #
    #   Rails.application.config.active_job.queue_adapter = :delayed_job
    class DelayedJobAdapter
      class << self
        def enqueue(job) #:nodoc:
          Delayed::Job.enqueue(JobWrapper.new(job.serialize), queue: job.queue_name)
        end

        def enqueue_at(job, timestamp) #:nodoc:
          Delayed::Job.enqueue(JobWrapper.new(job.serialize), queue: job.queue_name, run_at: Time.at(timestamp))
        end
      end

      class JobWrapper #:nodoc:
        attr_accessor :job_data

        def initialize(job_data)
          @job_data = job_data
        end

        def perform
          Base.execute(job_data)
        end
      end
    end
  end
end

Version data entries

48 entries across 47 versions & 8 rubygems

Version Path
activejob-4.2.5.1 lib/active_job/queue_adapters/delayed_job_adapter.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/delayed_job_adapter.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/delayed_job_adapter.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.5 lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.5.rc2 lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.5.rc1 lib/active_job/queue_adapters/delayed_job_adapter.rb
sc_core-0.0.7 test/dummy/vendor/bundle/ruby/2.2.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.4 lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.4.rc1 lib/active_job/queue_adapters/delayed_job_adapter.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/activejob-4.2.3/lib/active_job/queue_adapters/delayed_job_adapter.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/activejob-4.2.3/lib/active_job/queue_adapters/delayed_job_adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activejob-4.2.1/lib/active_job/queue_adapters/delayed_job_adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activejob-4.2.2/lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.3 lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.3.rc1 lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.2 lib/active_job/queue_adapters/delayed_job_adapter.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/activejob-4.2.1/lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.1 lib/active_job/queue_adapters/delayed_job_adapter.rb
activejob-4.2.1.rc4 lib/active_job/queue_adapters/delayed_job_adapter.rb