agent_propagate_job.rb 564B

1234567891011121314151617181920
  1. class AgentPropagateJob < ActiveJob::Base
  2. queue_as :propagation
  3. def perform
  4. Agent.receive!
  5. end
  6. def self.can_enqueue?
  7. if Rails.configuration.active_job.queue_adapter == :delayed_job &&
  8. Delayed::Job.where(failed_at: nil, queue: 'propagation').count > 0
  9. return false
  10. elsif Rails.configuration.active_job.queue_adapter == :resque &&
  11. (Resque.size('propagation') > 0 ||
  12. Resque.workers.select { |w| w.job && w.job['queue'] && w.job['queue']['propagation'] }.count > 0)
  13. return false
  14. end
  15. true
  16. end
  17. end