Module: Resque::Plugins::JobStats::Failed

Included in:
Resque::Plugins::JobStats
Defined in:
lib/resque/plugins/job_stats/failed.rb

Overview

Extend your job with this module to track how many jobs fail

Instance Method Summary collapse

Instance Method Details

#jobs_failedObject

Returns the number of jobs failed



15
16
17
18
19
# File 'lib/resque/plugins/job_stats/failed.rb', line 15

def jobs_failed
  jobs_failed = Resque.redis.get(jobs_failed_key).to_i
  return jobs_failed / 2 if Resque::VERSION == '1.20.0'
  jobs_failed
end

#jobs_failed=(int) ⇒ Object

Sets the number of jobs failed



10
11
12
# File 'lib/resque/plugins/job_stats/failed.rb', line 10

def jobs_failed=(int)
  Resque.redis.set(jobs_failed_key,int)
end

#jobs_failed_keyObject

Returns the key used for tracking jobs failed



22
23
24
# File 'lib/resque/plugins/job_stats/failed.rb', line 22

def jobs_failed_key
  "stats:jobs:#{self.name}:failed"
end

#on_failure_job_stats_failed(e, *args) ⇒ Object

Increments the failed count when job is complete



27
28
29
# File 'lib/resque/plugins/job_stats/failed.rb', line 27

def on_failure_job_stats_failed(e,*args)
  Resque.redis.incr(jobs_failed_key)
end