Sha256: b2fa02726cc8d70714f503ef7108f62cb9e17ae0ab00129453135feb3830c7d9
Contents?: true
Size: 615 Bytes
Versions: 5
Compression:
Stored size: 615 Bytes
Contents
module ::Delayed class StatusException < Exception end class Status def self.ok?(overdue=15.minutes) job = ::Delayed::StatusJob.first || ::Delayed::StatusJob.enqueue(::Delayed::StatusJob.new) failed_count = Delayed::Job.where('failed_at is not null').count raise(::Delayed::StatusException, "There are #{failed_count} failed jobs!" ) if failed_count > 0 elapsed_time = (Time.now - job.updated_at).to_i raise(::Delayed::StatusException, "Rails3 Status job hasn't run for #{elapsed_time} seconds" ) if elapsed_time > overdue true end end end
Version data entries
5 entries across 5 versions & 1 rubygems