Class: RactorRailsShim::WorkerApp
- Inherits:
-
Object
- Object
- RactorRailsShim::WorkerApp
- Defined in:
- lib/ractor_rails_shim/patches/core.rb
Overview
A shareable Rack wrapper that performs per-worker initialization lazily, inside the worker Ractor's request path (kino's :ractor mode has no per-worker init hook). On the first request served by a worker it:
1. rebinds the captured application constants into that worker's
namespace (so bare `Post` etc. resolve), then
2. ensures the worker's ActiveRecord connection handler is initialized.
The wrapper holds only shareable state (@app, @bindings), so the instance
is Ractor.make_shareable. Ractor.current provides per-worker storage for
the one-time guard, avoiding any top-level constant reference.
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, bindings) ⇒ WorkerApp
constructor
A new instance of WorkerApp.
Constructor Details
#initialize(app, bindings) ⇒ WorkerApp
Returns a new instance of WorkerApp.
771 772 773 774 |
# File 'lib/ractor_rails_shim/patches/core.rb', line 771 def initialize(app, bindings) @app = app @bindings = bindings end |
Instance Method Details
#call(env) ⇒ Object
776 777 778 779 |
# File 'lib/ractor_rails_shim/patches/core.rb', line 776 def call(env) setup_once! @app.call(env) end |