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

Class Method Summary collapse

Class Attribute Details

.cron_keyString?

Cron Key

Returns:

  • (String, nil)


12
# File 'lib/good_job/current_execution.rb', line 12

thread_mattr_accessor :cron_key

.error_on_discardException?

Error captured by discard_on

Returns:

  • (Exception, nil)


18
# File 'lib/good_job/current_execution.rb', line 18

thread_mattr_accessor :error_on_discard

.error_on_retryException?

Error captured by retry_on

Returns:

  • (Exception, nil)


24
# File 'lib/good_job/current_execution.rb', line 24

thread_mattr_accessor :error_on_retry

.good_jobGoodJob::Job?

Cron Key

Returns:



30
# File 'lib/good_job/current_execution.rb', line 30

thread_mattr_accessor :good_job

Class Method Details

.active_job_idString

Returns UUID of the currently executing GoodJob::Job.

Returns:

  • (String)

    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_idInteger

Returns Current process ID.

Returns:

  • (Integer)

    Current process ID



47
48
49
# File 'lib/good_job/current_execution.rb', line 47

def self.process_id
  Process.pid
end

.resetvoid

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_nameString

Returns Current thread name.

Returns:

  • (String)

    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