Sha256: d4d7465bd87dd7f1e90ca3c1a614da3e0d104aec5aba5bf9ac0966c7315deca3

Contents?: true

Size: 990 Bytes

Versions: 24

Compression:

Stored size: 990 Bytes

Contents

require 'active_support/core_ext/module/attribute_accessors_per_thread'

module GoodJob
  # Thread-local attributes for passing values from Instrumentation.
  # (Cannot use ActiveSupport::CurrentAttributes because ActiveJob resets it)

  module CurrentExecution
    # @!attribute [rw] error_on_retry
    #   @!scope class
    #   Error captured by retry_on
    #   @return [Exception, nil]
    thread_mattr_accessor :error_on_retry

    # @!attribute [rw] error_on_discard
    #   @!scope class
    #   Error captured by discard_on
    #   @return [Exception, nil]
    thread_mattr_accessor :error_on_discard

    # Resets attributes
    # @return [void]
    def self.reset
      self.error_on_retry = nil
      self.error_on_discard = nil
    end

    # @return [Integer] Current process ID
    def self.process_id
      Process.pid
    end

    # @return [String] Current thread name
    def self.thread_name
      (Thread.current.name || Thread.current.object_id).to_s
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
good_job-1.9.3 lib/good_job/current_execution.rb
good_job-1.9.2 lib/good_job/current_execution.rb
good_job-1.9.1 lib/good_job/current_execution.rb
good_job-1.9.0 lib/good_job/current_execution.rb
good_job-1.8.0 lib/good_job/current_execution.rb
good_job-1.7.1 lib/good_job/current_execution.rb
good_job-1.7.0 lib/good_job/current_execution.rb
good_job-1.6.0 lib/good_job/current_execution.rb
good_job-1.5.0 lib/good_job/current_execution.rb
good_job-1.4.1 lib/good_job/current_execution.rb
good_job-1.4.0 lib/good_job/current_execution.rb
good_job-1.3.6 lib/good_job/current_execution.rb
good_job-1.3.5 lib/good_job/current_execution.rb
good_job-1.3.4 lib/good_job/current_execution.rb
good_job-1.3.3 lib/good_job/current_execution.rb
good_job-1.3.2 lib/good_job/current_execution.rb
good_job-1.3.1 lib/good_job/current_execution.rb
good_job-1.3.0 lib/good_job/current_execution.rb
good_job-1.2.6 lib/good_job/current_execution.rb
good_job-1.2.5 lib/good_job/current_execution.rb