class BackgroundJobs::Sidekiq::JobQueue
Public Instance Methods
enqueue(job_type, job_id, attributes, options = {})
click to toggle source
# File lib/background_jobs/strategies/sidekiq/job_queue.rb, line 10 def enqueue(job_type, job_id, attributes, options = {}) priority = options[:priority] || 1 unique = options[:unique] || false at = (Time.now + options[:in]).to_i if options[:in] return if unique && is_scheduled?(job_type) queue = BackgroundJobs.job_registry.get_type(job_type) attributes.unshift job_id attributes.unshift job_type args = { 'queue' => queue.to_s, # queue by priority? 'class' => JobAdapter, 'args' => JobAttributesAdapter.new(attributes).encode } args['at'] = at if at ::Sidekiq::Client.push(args) end
Private Instance Methods
is_scheduled?(job_name)
click to toggle source
# File lib/background_jobs/strategies/sidekiq/job_queue.rb, line 34 def is_scheduled?(job_name) entries = ::Sidekiq::ScheduledSet.new.entries job_names = entries.map(&:item).map {|item| item['args'].first } job_names.include?(job_name.to_s) end