Sha256: 43a0c9749ac3023d61b01f7557f37a3281e282b575f6404dce24595a0e1a15a7

Contents?: true

Size: 1.34 KB

Versions: 33

Compression:

Stored size: 1.34 KB

Contents

require 'sidekiq'

module ActiveJob
  module QueueAdapters
    # == Sidekiq adapter for Active Job
    #
    # Simple, efficient background processing for Ruby. Sidekiq uses threads to
    # handle many jobs at the same time in the same process. It does not
    # require Rails but will integrate tightly with it to make background
    # processing dead simple.
    #
    # Read more about Sidekiq {here}[http://sidekiq.org].
    #
    # To use Sidekiq set the queue_adapter config to +:sidekiq+.
    #
    #   Rails.application.config.active_job.queue_adapter = :sidekiq
    class SidekiqAdapter
      class << self
        def enqueue(job) #:nodoc:
          #Sidekiq::Client does not support symbols as keys
          Sidekiq::Client.push \
            'class' => JobWrapper,
            'wrapped' => job.class.to_s,
            'queue' => job.queue_name,
            'args'  => [ job.serialize ]
        end

        def enqueue_at(job, timestamp) #:nodoc:
          Sidekiq::Client.push \
            'class' => JobWrapper,
            'wrapped' => job.class.to_s,
            'queue' => job.queue_name,
            'args'  => [ job.serialize ],
            'at'    => timestamp
        end
      end

      class JobWrapper #:nodoc:
        include Sidekiq::Worker

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

Version data entries

33 entries across 33 versions & 6 rubygems

Version Path
activejob-4.2.11.3 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.11.2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.11.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.11 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.10 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.10.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.9 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.9.rc2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.9.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activejob-4.2.8/lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.8 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.8.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.7.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.7 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.7.rc1 lib/active_job/queue_adapters/sidekiq_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/sidekiq_adapter.rb
activejob-4.2.6 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.6.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.5.2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-4.2.5.1 lib/active_job/queue_adapters/sidekiq_adapter.rb