Sha256: 5c0e32a6f6bdaca56e8759c41349624698e9443aa6ea6028293255a7d6f9a3c2

Contents?: true

Size: 989 Bytes

Versions: 5

Compression:

Stored size: 989 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

5 entries across 5 versions & 1 rubygems

Version Path
good_job-1.10.1 lib/good_job/current_execution.rb
good_job-1.10.0 lib/good_job/current_execution.rb
good_job-1.9.6 lib/good_job/current_execution.rb
good_job-1.9.5 lib/good_job/current_execution.rb
good_job-1.9.4 lib/good_job/current_execution.rb