Module: RactorRailsShim::Funnel

Defined in:
lib/ractor_rails_shim/foundation/funnel.rb

Class Method Summary collapse

Class Method Details

.debug=(value) ⇒ Object



30
31
32
# File 'lib/ractor_rails_shim/foundation/funnel.rb', line 30

def debug=(value)
  @debug = value
end

.debug?Boolean

When true, swallowed exceptions are reported to $stderr so a worker Ractor that later crashes on an unshareable value has a traceable cause. Default false (silent, the historical behaviour).

Returns:

  • (Boolean)


26
27
28
# File 'lib/ractor_rails_shim/foundation/funnel.rb', line 26

def debug?
  defined?(@debug) ? @debug : false
end

.swallow(label) ⇒ Object

Swallow an exception raised by the block, optionally logging it when debug? is on. label identifies the call site (e.g. "freeze AR ivar Post@column_defaults"). Keep the label short — it's only for grepping. Returns the block's value on success, nil on rescued StandardError.



39
40
41
42
43
44
# File 'lib/ractor_rails_shim/foundation/funnel.rb', line 39

def swallow(label)
  yield
rescue StandardError => e
  warn "[ractor_rails_shim] #{label}: #{e.class}: #{e.message[0, 120]}" if debug?
  nil
end