Module: GoodJob::CurrentExecution
- Defined in:
- lib/good_job/current_execution.rb
Overview
Thread-local attributes for passing values from Instrumentation. (Cannot use ActiveSupport::CurrentAttributes because ActiveJob resets it)
Class Attribute Summary collapse
-
.cron_key ⇒ String?
Cron Key.
-
.error_on_discard ⇒ Exception?
Error captured by discard_on.
-
.error_on_retry ⇒ Exception?
Error captured by retry_on.
-
.good_job ⇒ GoodJob::Job?
Cron Key.
Class Method Summary collapse
-
.active_job_id ⇒ String
UUID of the currently executing GoodJob::Job.
-
.process_id ⇒ Integer
Current process ID.
-
.reset ⇒ void
Resets attributes.
-
.thread_name ⇒ String
Current thread name.
Class Attribute Details
.cron_key ⇒ String?
Cron Key
12 |
# File 'lib/good_job/current_execution.rb', line 12 thread_mattr_accessor :cron_key |
.error_on_discard ⇒ Exception?
Error captured by discard_on
18 |
# File 'lib/good_job/current_execution.rb', line 18 thread_mattr_accessor :error_on_discard |
.error_on_retry ⇒ Exception?
Error captured by retry_on
24 |
# File 'lib/good_job/current_execution.rb', line 24 thread_mattr_accessor :error_on_retry |
.good_job ⇒ GoodJob::Job?
Cron Key
30 |
# File 'lib/good_job/current_execution.rb', line 30 thread_mattr_accessor :good_job |
Class Method Details
.active_job_id ⇒ String
Returns UUID of the currently executing GoodJob::Job.
42 43 44 |
# File 'lib/good_job/current_execution.rb', line 42 def self.active_job_id good_job&.active_job_id end |
.process_id ⇒ Integer
Returns Current process ID.
47 48 49 |
# File 'lib/good_job/current_execution.rb', line 47 def self.process_id Process.pid end |
.reset ⇒ void
This method returns an undefined value.
Resets attributes
34 35 36 37 38 39 |
# File 'lib/good_job/current_execution.rb', line 34 def self.reset self.cron_key = nil self.good_job = nil self.error_on_discard = nil self.error_on_retry = nil end |
.thread_name ⇒ String
Returns Current thread name.
52 53 54 |
# File 'lib/good_job/current_execution.rb', line 52 def self.thread_name (Thread.current.name || Thread.current.object_id).to_s end |