Module: RactorRailsShim::Callbacks
- Defined in:
- lib/ractor_rails_shim/callbacks.rb,
lib/ractor_rails_shim/callbacks/registry.rb,
lib/ractor_rails_shim/callbacks/symbolic_transport.rb,
lib/ractor_rails_shim/callbacks/dependent_association_transport.rb
Defined Under Namespace
Classes: DependentAssociationTransport, Registry, SymbolicTransport
Constant Summary collapse
- DECLARED_CALLBACKS_CONST =
The constant names the built-in transports resolve at replay time.
:SHAREABLE_DECLARED_CALLBACKS- DEPENDENT_ASSOCIATIONS_CONST =
:SHAREABLE_DEPENDENT_ASSOCIATIONS
Class Method Summary collapse
-
.build_default_registry ⇒ Object
Build a fresh Registry wired to the shim's shareable callback tables.
-
.registry ⇒ Object
The active Registry for THIS Ractor.
- .registry=(value) ⇒ Object
-
.reset_registry ⇒ Object
Forget the cached registry (e.g. after a re-prepare).
Class Method Details
.build_default_registry ⇒ Object
Build a fresh Registry wired to the shim's shareable callback tables. Public so tests/integration can rebuild after a re-prepare. The transports take the CONSTANT NAME (a Symbol) and resolve it themselves via const_get at replay time, so no main-Ractor-bound object crosses the boundary.
53 54 55 56 57 58 |
# File 'lib/ractor_rails_shim/callbacks.rb', line 53 def build_default_registry Registry.new([ SymbolicTransport.new(source: DECLARED_CALLBACKS_CONST), DependentAssociationTransport.new(source: DEPENDENT_ASSOCIATIONS_CONST) ]) end |
.registry ⇒ Object
The active Registry for THIS Ractor. Built once per Ractor and cached
in Ractor.current (a class ivar would raise IsolationError in workers).
Tests may replace it via registry= (per-Ractor) to inject fakes.
34 35 36 37 |
# File 'lib/ractor_rails_shim/callbacks.rb', line 34 def registry cache = Ractor.current cache[:rrs_callbacks_registry] ||= build_default_registry end |
.registry=(value) ⇒ Object
39 40 41 |
# File 'lib/ractor_rails_shim/callbacks.rb', line 39 def registry=(value) Ractor.current[:rrs_callbacks_registry] = value end |
.reset_registry ⇒ Object
Forget the cached registry (e.g. after a re-prepare). Per-Ractor.
44 45 46 |
# File 'lib/ractor_rails_shim/callbacks.rb', line 44 def reset_registry Ractor.current[:rrs_callbacks_registry] = nil end |