mirror of
https://github.com/Fishwaldo/huginn.git
synced 2025-03-16 03:41:41 +00:00
20 lines
673 B
Ruby
20 lines
673 B
Ruby
class AgentPropagateJob < ActiveJob::Base
|
|
queue_as :propagation
|
|
|
|
def perform
|
|
Agent.receive!
|
|
end
|
|
|
|
def self.can_enqueue?
|
|
case queue_adapter.class.name # not using class since it would load adapter dependent gems
|
|
when 'ActiveJob::QueueAdapters::DelayedJobAdapter'
|
|
return Delayed::Job.where(failed_at: nil, queue: 'propagation').count == 0
|
|
when 'ActiveJob::QueueAdapters::ResqueAdapter'
|
|
return Resque.size('propagation') == 0 &&
|
|
Resque.workers.select { |w| w.job && w.job['queue'] && w.job['queue']['propagation'] }.count == 0
|
|
else
|
|
raise NotImplementedError, "unsupported adapter: #{queue_adapter}"
|
|
end
|
|
end
|
|
|
|
end
|