Module: Resque::Plugins::QueueStats
- Defined in:
- lib/resque/plugins/queue_stats.rb
Instance Method Summary collapse
- #after_perform_queue_stats(*payload) ⇒ Object
- #around_perform_queue_stats(*payload) ⇒ Object
- #failed_count ⇒ Object
- #longest_job ⇒ Object
- #on_failure_queue_stats(e, *payload) ⇒ Object
- #performed_count ⇒ Object
- #reset_failed_count ⇒ Object
- #reset_longest_job ⇒ Object
- #reset_performed_count ⇒ Object
Instance Method Details
#after_perform_queue_stats(*payload) ⇒ Object
31 32 33 |
# File 'lib/resque/plugins/queue_stats.rb', line 31 def after_perform_queue_stats(*payload) Resque.redis.incr("stat:queue:#{@queue}:performed") end |
#around_perform_queue_stats(*payload) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/resque/plugins/queue_stats.rb', line 35 def around_perform_queue_stats(*payload) start = Time.now yield total_time = Time.now - start Resque.redis.multi do if longest_job.to_f < total_time.to_f Resque.redis.set("stat:queue:#{@queue}:longest_job",total_time) end end end |
#failed_count ⇒ Object
15 16 17 |
# File 'lib/resque/plugins/queue_stats.rb', line 15 def failed_count Resque.redis.get("stat:queue:#{@queue}:failed").to_i end |
#longest_job ⇒ Object
23 24 25 |
# File 'lib/resque/plugins/queue_stats.rb', line 23 def longest_job Resque.redis.get("stat:queue:#{@queue}:longest_job").to_f end |
#on_failure_queue_stats(e, *payload) ⇒ Object
49 50 51 |
# File 'lib/resque/plugins/queue_stats.rb', line 49 def on_failure_queue_stats(e,*payload) Resque.redis.incr("stat:queue:#{@queue}:failed") end |
#performed_count ⇒ Object
7 8 9 |
# File 'lib/resque/plugins/queue_stats.rb', line 7 def performed_count Resque.redis.get("stat:queue:#{@queue}:performed").to_i end |
#reset_failed_count ⇒ Object
19 20 21 |
# File 'lib/resque/plugins/queue_stats.rb', line 19 def reset_failed_count Resque.redis.set("stat:queue:#{@queue}:failed",0) end |
#reset_longest_job ⇒ Object
27 28 29 |
# File 'lib/resque/plugins/queue_stats.rb', line 27 def reset_longest_job Resque.redis.set("stat:queue:#{@queue}:longest_job",0.0) end |
#reset_performed_count ⇒ Object
11 12 13 |
# File 'lib/resque/plugins/queue_stats.rb', line 11 def reset_performed_count Resque.redis.set("stat:queue:#{@queue}:performed",0) end |