Sha256: 6c91bd33dcf6e0b5993586e50758fa3308c9b0c6ebae5651654359e63635f0b5

Contents?: true

Size: 1.4 KB

Versions: 40

Compression:

Stored size: 1.4 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.to_s,
          "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.to_s,
          "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

40 entries across 40 versions & 3 rubygems

Version Path
chatops-rpc-0.0.1 fixtures/chatops-controller-example/vendor/bundle/ruby/2.5.0/gems/activejob-6.0.0/lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-6.0.0 lib/active_job/queue_adapters/sidekiq_adapter.rb
spiral_form-0.1.1 vendor/bundle/gems/activejob-5.2.3/lib/active_job/queue_adapters/sidekiq_adapter.rb
spiral_form-0.1.0 vendor/bundle/gems/activejob-5.2.3/lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-6.0.0.rc2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-6.0.0.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.3 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.3.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-6.0.0.beta3 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.2.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-6.0.0.beta2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-6.0.0.beta1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.2.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.1.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.1.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.0 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.0.rc2 lib/active_job/queue_adapters/sidekiq_adapter.rb
activejob-5.2.0.rc1 lib/active_job/queue_adapters/sidekiq_adapter.rb