Sha256: 5b07a1df354b15b658c297b73f065829a02d848361f9f7edd38d9e3fc0113ba4
Contents?: true
Size: 1.49 KB
Versions: 9
Compression:
Stored size: 1.49 KB
Contents
module Kthxbye module Failure include Helper extend Helper def self.all redis.hvals( :failed ).sort.map{|x| decode( x )} end # returns a specified failed job data def self.find(id) decode( redis.hget( :failed, id ) ) end # gets count of all errors def self.count redis.hkeys( :failed ).size end # gets count of all errors of a specific type def self.count_type(type) vals = redis.hvals( :failed ) vals.each {|x| o = decode(x); vals.delete x if o['type'] !~ /#{type.to_s}/} vals.size end # creates a Failure object. def self.create(job, exception) failed_attempts = (Failure.find(job.id)['attempts'].to_i + 1) if redis.hexists( :failed, job.id ) error = { :type => exception.class.to_s, :error => exception.to_s, :job => job.id, :queue => job.queue, :time => Time.now, :backtrace => Array( exception.backtrace ), :attempts => (failed_attempts || 1) } redis.hset( :failed, job.id, encode( error ) ) job.dequeue end def self.rerun(id) failure = Failure.find(id) Job.find(id, failure['queue']).rerun end def self.fails_for_job(id) failure = decode( redis.hget( :failed, id ) ) return failure ? failure['attempts'] : 0 end # the only method allowed to clear exceptions out of the exception store def self.clear_exception(id) redis.hdel( :failed, id ) end end end
Version data entries
9 entries across 9 versions & 1 rubygems