Class: Rigor::Plugin::Blueprint
- Inherits:
-
Object
- Object
- Rigor::Plugin::Blueprint
- Defined in:
- lib/rigor/plugin/blueprint.rb,
sig/rigor/plugin/blueprint.rbs
Overview
Frozen, Ractor.shareable? description of how to materialise a single plugin instance inside a worker.
ADR-15 Phase 3 introduces the carrier so the eventual worker
pool can pass Array<Blueprint> across a Ractor boundary verbatim; each worker calls #materialize once
at startup, then owns its plugin instances (and their mutable per-run accumulators) for the lifetime of
the worker.
Holds the constant path (String) of the plugin class — NOT the class object itself. Plugin gems are
required from the main Ractor BEFORE any worker spawns, so every Ractor resolves the same constant via
Object.const_get.
The config Hash is deep-copied + made shareable at construction so the Blueprint stays decoupled from
whatever Hash the project configuration emitted. The original config Hash held by the loader is therefore
unaffected by Blueprint construction.
Instance Attribute Summary collapse
-
#config ⇒ Hash[untyped, untyped]
readonly
Returns the value of attribute config.
-
#klass_name ⇒ String
readonly
Returns the value of attribute klass_name.
Instance Method Summary collapse
-
#initialize(klass_name:, config: {}) ⇒ Blueprint
constructor
A new instance of Blueprint.
-
#materialize(services:) ⇒ Rigor::Plugin::Base
Resolves the plugin class via
Object.const_get, builds a fresh instance bound to the supplied services container, and calls#init(services).
Constructor Details
#initialize(klass_name:, config: {}) ⇒ Blueprint
Returns a new instance of Blueprint.
21 22 23 24 25 |
# File 'lib/rigor/plugin/blueprint.rb', line 21 def initialize(klass_name:, config: {}) @klass_name = normalise_klass_name(klass_name) @config = Ractor.make_shareable(Marshal.load(Marshal.dump(config))) freeze end |
Instance Attribute Details
#config ⇒ Hash[untyped, untyped] (readonly)
Returns the value of attribute config.
19 20 21 |
# File 'lib/rigor/plugin/blueprint.rb', line 19 def config @config end |
#klass_name ⇒ String (readonly)
Returns the value of attribute klass_name.
19 20 21 |
# File 'lib/rigor/plugin/blueprint.rb', line 19 def klass_name @klass_name end |
Instance Method Details
#materialize(services:) ⇒ Rigor::Plugin::Base
Resolves the plugin class via Object.const_get, builds a fresh instance bound to the supplied services
container, and calls #init(services). Mirrors Loader#instantiate bit-for-bit so the
blueprint-driven path stays consistent with the configuration-driven load path.
30 31 32 33 34 35 |
# File 'lib/rigor/plugin/blueprint.rb', line 30 def materialize(services:) klass = Object.const_get(@klass_name) plugin = klass.new(services: services, config: @config) plugin.init(services) plugin end |