Module: ActiveJobLog::LogExt
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/active_job_log/log_ext.rb
Instance Method Summary collapse
- #enqueue_job(job) ⇒ Object
- #execute_job(job) ⇒ Object
- #fail_job(exception) ⇒ Object
- #finish_job(job) ⇒ Object
- #init_params(job) ⇒ Object
- #update_job!(job_id, status, params = {}) ⇒ Object
Instance Method Details
#enqueue_job(job) ⇒ Object
24 25 26 |
# File 'lib/active_job_log/log_ext.rb', line 24 def enqueue_job(job) update_job!(job.job_id, :queued, init_params(job)) end |
#execute_job(job) ⇒ Object
28 29 30 |
# File 'lib/active_job_log/log_ext.rb', line 28 def execute_job(job) update_job!(job.job_id, :pending, init_params(job)) end |
#fail_job(exception) ⇒ Object
36 37 38 39 40 41 42 43 |
# File 'lib/active_job_log/log_ext.rb', line 36 def fail_job(exception) update_job!( job_id, :failed, error: exception., stack_trace: exception.backtrace ) end |
#finish_job(job) ⇒ Object
32 33 34 |
# File 'lib/active_job_log/log_ext.rb', line 32 def finish_job(job) update_job!(job.job_id, :finished) end |
#init_params(job) ⇒ Object
51 52 53 54 55 56 57 58 |
# File 'lib/active_job_log/log_ext.rb', line 51 def init_params(job) { job_class: self.class.name, params: job.arguments, executions: job.try(:executions), queue_name: job.queue_name } end |
#update_job!(job_id, status, params = {}) ⇒ Object
45 46 47 48 49 |
# File 'lib/active_job_log/log_ext.rb', line 45 def update_job!(job_id, status, params = {}) return if self.class.disabled_log Job.update_job!(job_id, status, params) end |