Sha256: c5087afe4967bca535adf70919de938309bb2b98de991e98e6472e172b2bb8e7

Contents?: true

Size: 1.39 KB

Versions: 37

Compression:

Stored size: 1.39 KB

Contents

# frozen_string_literal: true

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
      def enqueue(job) # :nodoc:
        # Sidekiq::Client does not support symbols as keys
        job.provider_job_id = Sidekiq::Client.push \
          "class"   => JobWrapper,
          "wrapped" => job.class,
          "queue"   => job.queue_name,
          "args"    => [ job.serialize ]
      end

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

      class JobWrapper # :nodoc:
        include Sidekiq::Worker

        def perform(job_data)
          Base.execute job_data.merge("provider_job_id" => jid)
        end
      end
    end
  end
end

Version data entries

37 entries across 35 versions & 4 rubygems

Version Path
activejob-7.0.8.6 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.8.5 lib/active_job/queue_adapters/sidekiq_adapter.rb
blacklight-spotlight-3.6.0.beta8 vendor/bundle/ruby/3.2.0/gems/activejob-7.0.8.4/lib/active_job/queue_adapters/sidekiq_adapter.rb
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/active_job/queue_adapters/sidekiq_adapter.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/active_job/queue_adapters/sidekiq_adapter.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/activejob-7.0.5.1/lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.8.4 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.8.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-7.0.3.1/lib/active_job/queue_adapters/sidekiq_adapter.rb
scrapbook-0.3.2 vendor/ruby/2.7.0/gems/activejob-7.0.2.3/lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.8 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.7.2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.7.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.7 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.6 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.5.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activejob-7.0.2.3/lib/active_job/queue_adapters/sidekiq_adapter.rb
scrapbook-0.3.1 vendor/ruby/2.7.0/gems/activejob-7.0.3.1/lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.5 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-7.0.4.3 lib/active_job/queue_adapters/sidekiq_adapter.rb