Module: Axn::Core::NestingTracking

Defined in:
lib/axn/core/nesting_tracking.rb

Class Method Summary collapse

Class Method Details

._current_axn_stackObject

Shared method for both class and instance access



7
8
9
# File 'lib/axn/core/nesting_tracking.rb', line 7

def self._current_axn_stack
  ActiveSupport::IsolatedExecutionState[:_axn_stack] ||= []
end

._reset_isolation_warning!Object

Re-arms the once-per-process warning above, for a spec suite that asserts on it. Named for the caller it exists for: Axn::Testing.reset! is the supported entry point.



57
58
59
# File 'lib/axn/core/nesting_tracking.rb', line 57

def self._reset_isolation_warning!
  remove_instance_variable(:@_isolation_mismatch_warned) if instance_variable_defined?(:@_isolation_mismatch_warned)
end

.tracking(axn) ⇒ Object

Tracks nesting of axn calls for logging/debugging purposes



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/axn/core/nesting_tracking.rb', line 12

def self.tracking(axn)
  # Opening a fresh call tree (empty stack): clear any per-execution exception bookkeeping that
  # a prior run might have left behind without draining the stack (e.g. an executor invoked
  # outside this wrapper, or an aborted teardown). Defends against a stale "already reported"
  # mark on a reused thread/fiber silently suppressing a real report.
  if _current_axn_stack.empty?
    Axn::Internal::ExceptionClassification.reset!
    Axn::Internal::CarriedPresentation.reset!
    _warn_if_fiber_isolation_mismatch
  end
  _current_axn_stack.push(axn)
  yield
ensure
  _current_axn_stack.pop
  # Outermost action finished: clear per-execution exception bookkeeping so the same exception
  # object re-raised by a later, independent run starts fresh (report dedup + fails_on
  # stickiness are scoped to one call tree).
  if _current_axn_stack.empty?
    Axn::Internal::ExceptionClassification.reset!
    Axn::Internal::CarriedPresentation.reset!
  end
end