Sha256: 89f8c6cb1bc0208cae145db83a27c3c9ac7a4782b2f2b448e2f0a8ecb6af1ef6

Contents?: true

Size: 1.45 KB

Versions: 51

Compression:

Stored size: 1.45 KB

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
    # == Resque adapter for Active Job
    #
    # Resque (pronounced like "rescue") is a Redis-backed library for creating
    # background jobs, placing those jobs on multiple queues, and processing
    # them later.
    #
    # Read more about Resque {here}[https://github.com/resque/resque].
    #
    # To use Resque set the queue_adapter config to +:resque+.
    #
    #   Rails.application.config.active_job.queue_adapter = :resque
    class ResqueAdapter
      class << self
        def enqueue(job) #:nodoc:
          Resque.enqueue_to job.queue_name, JobWrapper, job.serialize
        end

        def enqueue_at(job, timestamp) #:nodoc:
          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 #:nodoc:
        class << self
          def perform(job_data)
            Base.execute job_data
          end
        end
      end
    end
  end
end

Version data entries

51 entries across 50 versions & 8 rubygems

Version Path
activejob-4.2.11.3 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.11.2 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.11.1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.11 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.10 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.10.rc1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.9 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.9.rc2 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.9.rc1 lib/active_job/queue_adapters/resque_adapter.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activejob-4.2.8/lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.8 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.8.rc1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.7.1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.7 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.7.rc1 lib/active_job/queue_adapters/resque_adapter.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activejob-4.2.6/lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.6 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.6.rc1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-4.2.5.2 lib/active_job/queue_adapters/resque_adapter.rb
activejob-lock-0.0.2 rails/activejob/lib/active_job/queue_adapters/resque_adapter.rb