Class: ActiveJob::QueueAdapters::SidekiqAdapter
Relationships & Source Files | |
Namespace Children | |
Classes:
| |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
AbstractAdapter
|
|
Instance Chain:
self,
AbstractAdapter
|
|
Inherits: |
ActiveJob::QueueAdapters::AbstractAdapter
|
Defined in: | activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb |
Overview
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.
To use Sidekiq set the queue_adapter config to :sidekiq
.
Rails.application.config.active_job.queue_adapter = :sidekiq
Instance Method Summary
- #enqueue(job) Internal use only
- #enqueue_all(jobs) Internal use only
- #enqueue_at(job, timestamp) Internal use only
AbstractAdapter
- Inherited
Instance Method Details
#enqueue(job)
This method is for internal use only.
[ GitHub ]
# File 'activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb', line 21
def enqueue(job) # :nodoc: job.provider_job_id = JobWrapper.set( wrapped: job.class, queue: job.queue_name ).perform_async(job.serialize) end
#enqueue_all(jobs)
This method is for internal use only.
[ GitHub ]
# File 'activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb', line 35
def enqueue_all(jobs) # :nodoc: enqueued_count = 0 jobs.group_by(&:class).each do |job_class, same_class_jobs| same_class_jobs.group_by(&:queue_name).each do |queue, same_class_and_queue_jobs| immediate_jobs, scheduled_jobs = same_class_and_queue_jobs.partition { |job| job.scheduled_at.nil? } if immediate_jobs.any? jids = Sidekiq::Client.push_bulk( "class" => JobWrapper, "wrapped" => job_class, "queue" => queue, "args" => immediate_jobs.map { |job| [job.serialize] }, ) enqueued_count += jids.compact.size end if scheduled_jobs.any? jids = Sidekiq::Client.push_bulk( "class" => JobWrapper, "wrapped" => job_class, "queue" => queue, "args" => scheduled_jobs.map { |job| [job.serialize] }, "at" => scheduled_jobs.map { |job| job.scheduled_at&.to_f } ) enqueued_count += jids.compact.size end end end enqueued_count end
#enqueue_at(job, timestamp)
This method is for internal use only.
[ GitHub ]
# File 'activejob/lib/active_job/queue_adapters/sidekiq_adapter.rb', line 28
def enqueue_at(job, ) # :nodoc: job.provider_job_id = JobWrapper.set( wrapped: job.class, queue: job.queue_name, ).perform_at(, job.serialize) end