Module: Resque::Plugins::JobHistory::ClassMethods
- Defined in:
- lib/resque/plugins/job_history.rb
Overview
The class methods added to the job class that is being enqueued and whose history is to be recorded.
Instance Method Summary collapse
- #around_perform_job_history(*args) ⇒ Object
- #exclude_from_linear_history ⇒ Object
- #job_history ⇒ Object
- #job_history_len ⇒ Object
- #most_recent_job ⇒ Object
- #most_recent_job=(job) ⇒ Object
- #on_failure_job_history(error, *args) ⇒ Object
- #page_size ⇒ Object
- #purge_age ⇒ Object
Instance Method Details
#around_perform_job_history(*args) ⇒ Object
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/resque/plugins/job_history.rb', line 53 def around_perform_job_history(*args) start_time = Time.now running_job = Resque::Plugins::JobHistory::Job.new(active_job_class_name(*args), SecureRandom.uuid) self.most_recent_job = running_job begin running_job.start(*active_job_args(*args)) yield if block_given? running_job.finish(start_time, *args) rescue StandardError => exception running_job.failed exception, start_time, *args raise ensure if running_job.present? && !running_job.finished? && !running_job.error running_job.cancel(" Job did not signal completion on finish.", start_time, *args) end self.most_recent_job = nil end end |
#exclude_from_linear_history ⇒ Object
88 89 90 |
# File 'lib/resque/plugins/job_history.rb', line 88 def exclude_from_linear_history @exclude_from_linear_history ||= false end |
#job_history ⇒ Object
92 93 94 |
# File 'lib/resque/plugins/job_history.rb', line 92 def job_history Resque::Plugins::JobHistory::HistoryDetails.new(name) end |
#job_history_len ⇒ Object
76 77 78 |
# File 'lib/resque/plugins/job_history.rb', line 76 def job_history_len @job_history_len ||= Resque::Plugins::JobHistory::MAX_JOB_HISTORY end |
#most_recent_job ⇒ Object
100 101 102 |
# File 'lib/resque/plugins/job_history.rb', line 100 def most_recent_job @most_recent_job end |
#most_recent_job=(job) ⇒ Object
96 97 98 |
# File 'lib/resque/plugins/job_history.rb', line 96 def most_recent_job=(job) @most_recent_job = job end |
#on_failure_job_history(error, *args) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/resque/plugins/job_history.rb', line 41 def on_failure_job_history(error, *args) job_class_name = active_job_class_name(*args) job_args = *active_job_args(*args) failed_job = find_failed_job(job_args, job_class_name) return unless failed_job return if failed_job.finished? && failed_job.error.present? failed_job.failed(error) end |
#page_size ⇒ Object
84 85 86 |
# File 'lib/resque/plugins/job_history.rb', line 84 def page_size @page_size ||= Resque::Plugins::JobHistory::PAGE_SIZE end |
#purge_age ⇒ Object
80 81 82 |
# File 'lib/resque/plugins/job_history.rb', line 80 def purge_age @purge_jobs_after ||= Resque::Plugins::JobHistory::PURGE_AGE end |