Sha256: 9e7208c499b6bd14c2714e5b02be9be6a0017c4fd51ca361a75b55caab30615b

Contents?: true

Size: 1.49 KB

Versions: 108

Compression:

Stored size: 1.49 KB

Contents

# frozen_string_literal: true

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
      def enqueue(job) #:nodoc:
        JobWrapper.instance_variable_set(:@queue, job.queue_name)
        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

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

Version data entries

108 entries across 108 versions & 8 rubygems

Version Path
activejob-6.1.7.10 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.9 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.8 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.7 lib/active_job/queue_adapters/resque_adapter.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.6 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.5 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.4 lib/active_job/queue_adapters/resque_adapter.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activejob-6.1.6.1/lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.3 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.2 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7.1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.0.6.1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.7 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.0.6 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.1.6.1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.0.5.1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-5.2.8.1 lib/active_job/queue_adapters/resque_adapter.rb
activejob-5.2.8 lib/active_job/queue_adapters/resque_adapter.rb
activejob-6.0.5 lib/active_job/queue_adapters/resque_adapter.rb