Sha256: 028d4790f484099d5eada9d3447a3155ccf6ed525528a301741128e5498ef239

Contents?: true

Size: 1.2 KB

Versions: 49

Compression:

Stored size: 1.2 KB

Contents

require 'qu'

module ActiveJob
  module QueueAdapters
    # == Qu adapter for Active Job
    #
    # Qu is a Ruby library for queuing and processing background jobs. It is
    # heavily inspired by delayed_job and Resque. Qu was created to overcome
    # some shortcomings in the existing queuing libraries.
    # The advantages of Qu are: Multiple backends (redis, mongo), jobs are
    # requeued when worker is killed, resque-like API.
    #
    # Read more about Qu {here}[https://github.com/bkeepers/qu].
    #
    # To use Qu set the queue_adapter config to +:qu+.
    #
    #   Rails.application.config.active_job.queue_adapter = :qu
    class QuAdapter
      class << self
        def enqueue(job, *args) #:nodoc:
          Qu::Payload.new(klass: JobWrapper, args: [job.serialize]).tap do |payload|
            payload.instance_variable_set(:@queue, job.queue_name)
          end.push
        end

        def enqueue_at(job, timestamp, *args) #:nodoc:
          raise NotImplementedError
        end
      end

      class JobWrapper < Qu::Job #:nodoc:
        def initialize(job_data)
          @job_data  = job_data
        end

        def perform
          Base.execute @job_data
        end
      end
    end
  end
end

Version data entries

49 entries across 48 versions & 8 rubygems

Version Path
activejob-4.2.5.1 lib/active_job/queue_adapters/qu_adapter.rb
angular-rails4-templates-0.4.1 vendor/ruby/2.1.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/qu_adapter.rb
angular-rails4-templates-0.4.0 vendor/ruby/2.1.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/qu_adapter.rb
angular-rails4-templates-0.3.0 vendor/ruby/2.1.0/gems/activejob-4.2.4/lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.5 lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.5.rc2 lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.5.rc1 lib/active_job/queue_adapters/qu_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/qu_adapter.rb
activejob-4.2.4 lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.4.rc1 lib/active_job/queue_adapters/qu_adapter.rb
solidus_backend-1.0.0.pre3 vendor/bundle/gems/activejob-4.2.3/lib/active_job/queue_adapters/qu_adapter.rb
solidus_backend-1.0.0.pre2 vendor/bundle/gems/activejob-4.2.3/lib/active_job/queue_adapters/qu_adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activejob-4.2.1/lib/active_job/queue_adapters/qu_adapter.rb
solidus_backend-1.0.0.pre vendor/bundle/gems/activejob-4.2.2/lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.3 lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.3.rc1 lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.2 lib/active_job/queue_adapters/qu_adapter.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/activejob-4.2.1/lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.1 lib/active_job/queue_adapters/qu_adapter.rb
activejob-4.2.1.rc4 lib/active_job/queue_adapters/qu_adapter.rb