Class: GoodJob::Execution
Constant Summary
Constants included
from ErrorEvents
GoodJob::ErrorEvents::DISCARDED, GoodJob::ErrorEvents::HANDLED, GoodJob::ErrorEvents::INTERRUPTED, GoodJob::ErrorEvents::RETRIED, GoodJob::ErrorEvents::RETRY_STOPPED, GoodJob::ErrorEvents::UNHANDLED
Instance Method Summary
collapse
Methods inherited from BaseRecord
bind_value, lease_connection, migrated?, migration_pending_warning!, with_logger_silenced
Instance Method Details
#display_serialized_params ⇒ Object
64
65
66
67
68
|
# File 'app/models/good_job/execution.rb', line 64
def display_serialized_params
serialized_params.merge({
_good_job_execution: attributes.except('serialized_params'),
})
end
|
#duration ⇒ Object
18
19
20
21
22
23
|
# File 'app/models/good_job/execution.rb', line 18
def duration
value = read_attribute(:duration)
return value if value.nil? || value.is_a?(::ActiveSupport::Duration)
value.to_f.seconds
end
|
#filtered_error_backtrace ⇒ Object
70
71
72
|
# File 'app/models/good_job/execution.rb', line 70
def filtered_error_backtrace
Rails.backtrace_cleaner.clean(error_backtrace || [])
end
|
#interrupted_duration ⇒ Object
58
59
60
61
62
|
# File 'app/models/good_job/execution.rb', line 58
def interrupted_duration
return unless error_event == "interrupted" && finished_at && performed_at
finished_at - performed_at
end
|
#last_status_at ⇒ Object
40
41
42
|
# File 'app/models/good_job/execution.rb', line 40
def last_status_at
finished_at || created_at
end
|
#number ⇒ Object
26
27
28
|
# File 'app/models/good_job/execution.rb', line 26
def number
serialized_params.fetch('executions', 0) + 1
end
|
#queue_latency ⇒ Object
Time between when this job was expected to run and when it started running
31
32
33
|
# File 'app/models/good_job/execution.rb', line 31
def queue_latency
created_at - scheduled_at
end
|
#runtime_latency ⇒ Object
Monotonic time between when this job started and finished
36
37
38
|
# File 'app/models/good_job/execution.rb', line 36
def runtime_latency
duration
end
|
#status ⇒ Object
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'app/models/good_job/execution.rb', line 44
def status
if finished_at.present?
if error.present? && job.finished_at.present?
:discarded
elsif error.present?
:retried
else
:succeeded
end
else
:running
end
end
|