Sha256: 48560fed5dde9cac732f402b157782ddff15fef909695c872c4736882b5e95d9

Contents?: true

Size: 1014 Bytes

Versions: 5

Compression:

Stored size: 1014 Bytes

Contents

require 'resque'
require 'active_support/core_ext/enumerable'
require 'active_support/core_ext/array/access'

begin
  require 'resque-scheduler'
rescue LoadError
  begin
    require 'resque_scheduler'
  rescue LoadError
    false
  end
end

module ActiveJob
  module QueueAdapters
    class ResqueAdapter
      class << self
        def enqueue(job)
          Resque.enqueue_to job.queue_name, JobWrapper, job.serialize
        end

        def enqueue_at(job, timestamp)
          unless Resque.respond_to?(:enqueue_at_with_queue)
            raise NotImplementedError, "To be able to schedule jobs with Resque you need the " \
              "resque-scheduler gem. Please add it to your Gemfile and run bundle install"
          end
          Resque.enqueue_at_with_queue job.queue_name, timestamp, JobWrapper, job.serialize
        end
      end

      class JobWrapper
        class << self
          def perform(job_data)
            Base.execute job_data
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
activejob_backport-0.0.3 lib/active_job/queue_adapters/resque_adapter.rb
passive_job-0.0.3 lib/active_job/queue_adapters/resque_adapter.rb
passive_job-0.0.2 lib/active_job/queue_adapters/resque_adapter.rb
activejob_backport-0.0.2 lib/active_job/queue_adapters/resque_adapter.rb
activejob_backport-0.0.1 lib/active_job/queue_adapters/resque_adapter.rb