Module: QueueProcessor::DependentCalculationGroup::QueueControl
Defined Under Namespace
Classes: CalculationRequest
Instance Method Summary
collapse
Instance Method Details
#delayed_job_options ⇒ Object
34
35
36
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 34
def delayed_job_options
{:priority=>priority, :run_at => run_at, :queue => queue}.reject {|k,v| v.nil?}
end
|
#delayed_jobs ⇒ Object
18
19
20
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 18
def delayed_jobs
Delayed::Backend::ActiveRecord::Job.where("handler ilike '%DependentCalculationGroup::QueueControl::CalculationRequest%' and handler like '%id: #{id}%'")
end
|
#dependencies_in_queue? ⇒ Boolean
30
31
32
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 30
def dependencies_in_queue?
dependent_calculations.inject(false) { |result, dependent_calculation| result || dependent_calculation.in_queue? }
end
|
#describe ⇒ Object
10
11
12
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 10
def describe
"#{self.class.to_s} - queue dependencies"
end
|
#in_queue? ⇒ Boolean
26
27
28
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 26
def in_queue?
delayed_jobs.count > 0
end
|
#queue_work ⇒ Object
14
15
16
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 14
def queue_work
Delayed::Job.enqueue(CalculationRequest.new(id, describe, self.class), delayed_job_options)
end
|
#should_cancel? ⇒ Boolean
6
7
8
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 6
def should_cancel?
parent_calculation.nil? || parent_calculation.calculation_stale?
end
|
#something_queued? ⇒ Boolean
22
23
24
|
# File 'lib/queue-processor/dependent_calculation_group/queue_control.rb', line 22
def something_queued?
in_queue? || dependencies_in_queue?
end
|