module BloodContracts::Instrumentation::SessionFinalizer

Top-level interface for Instrument finalizers

Constants

DEFAULT_POOL_SIZE

@private

FINALIZERS

Names of finalizers

@return [Array<Symbol>]

WRONG_FINALIZER_MSG

@private

Public Instance Methods

init(name, **opts) click to toggle source

Reset the finalizer by name

@param name [Symbol] finalizer to find @param **opts [Hash] options passed to finalizer constructor

@return [#finalize!]

# File lib/blood_contracts/instrumentation/session_finalizer.rb, line 41
def init(name, **opts)
  Thread.current[:bc_session_finalizer] = find_finalizer_by(name, **opts)
end
instance() click to toggle source

Current thread instance of the Session finalizer

@return [#finalize!]

# File lib/blood_contracts/instrumentation/session_finalizer.rb, line 29
def instance
  Thread.current[:bc_session_finalizer] ||=
    Instrumentation.reset_session_finalizer!
end

Private Instance Methods

find_finalizer_by(name, pool_size: DEFAULT_POOL_SIZE) click to toggle source

@private

# File lib/blood_contracts/instrumentation/session_finalizer.rb, line 46
        def find_finalizer_by(name, pool_size: DEFAULT_POOL_SIZE)
  case name
  when :basic
    Basic
  when :fibers
    Fibers.new(pool_size)
  when :threads
    Threads
  else
    raise ArgumentError, WRONG_FINALIZER_MSG
  end
end