Class: Rigor::Plugin::Registry
- Inherits:
-
Object
- Object
- Rigor::Plugin::Registry
- Defined in:
- lib/rigor/plugin/registry.rb
Overview
Read-side query API over the plugins loaded for a single ‘Analysis::Runner.run`. Constructed by Loader.load and exposed downstream so the contribution merger (slice 3) and diagnostic provenance (slice 5) can iterate over loaded plugin instances in deterministic order.
The registry is read-only after construction; ordering is the order in which Loader resolved configuration entries, which is project-config order with plugin-id alphabetical as the tie-breaker.
ADR-15 Phase 3 — alongside the instantiated ‘plugins`, the registry carries `blueprints`: a frozen, Ractor-shareable `Array<Blueprint>` that records how to re-instantiate the same plugin set in a worker Ractor. The eventual Phase 4 pool ships `blueprints` across the boundary and calls Registry.materialize per-Ractor; the live `plugins` carriage on the coordinator registry stays unchanged.
Constant Summary collapse
- EMPTY =
new.freeze
Instance Attribute Summary collapse
-
#blueprints ⇒ Object
readonly
Returns the value of attribute blueprints.
-
#load_errors ⇒ Object
readonly
Returns the value of attribute load_errors.
-
#plugins ⇒ Object
readonly
Returns the value of attribute plugins.
Class Method Summary collapse
-
.materialize(blueprints:, services:) ⇒ Object
ADR-15 Phase 3 — build a fresh Registry from the supplied blueprint set by replaying Blueprint#materialize per entry against ‘services`.
Instance Method Summary collapse
- #any_load_errors? ⇒ Boolean
- #empty? ⇒ Boolean
- #find(id) ⇒ Object
- #ids ⇒ Object
-
#initialize(plugins: [], load_errors: [], blueprints: []) ⇒ Registry
constructor
A new instance of Registry.
-
#type_node_resolvers ⇒ Object
ADR-13 slice 2 — flat ordered list of every loaded plugin’s manifest-declared TypeNodeResolver instances, in plugin registration order.
Constructor Details
#initialize(plugins: [], load_errors: [], blueprints: []) ⇒ Registry
Returns a new instance of Registry.
39 40 41 42 43 44 |
# File 'lib/rigor/plugin/registry.rb', line 39 def initialize(plugins: [], load_errors: [], blueprints: []) @plugins = plugins.dup.freeze @load_errors = load_errors.dup.freeze @blueprints = blueprints.dup.freeze freeze end |
Instance Attribute Details
#blueprints ⇒ Object (readonly)
Returns the value of attribute blueprints.
27 28 29 |
# File 'lib/rigor/plugin/registry.rb', line 27 def blueprints @blueprints end |
#load_errors ⇒ Object (readonly)
Returns the value of attribute load_errors.
27 28 29 |
# File 'lib/rigor/plugin/registry.rb', line 27 def load_errors @load_errors end |
#plugins ⇒ Object (readonly)
Returns the value of attribute plugins.
27 28 29 |
# File 'lib/rigor/plugin/registry.rb', line 27 def plugins @plugins end |
Class Method Details
.materialize(blueprints:, services:) ⇒ Object
ADR-15 Phase 3 — build a fresh Registry from the supplied blueprint set by replaying Blueprint#materialize per entry against ‘services`. The returned registry carries NEW plugin instances (mutable per-Ractor accumulators included) and the same blueprint set, so a worker can hand the materialised registry to Environment without losing the replay handle. `load_errors` is intentionally empty: load-time failures already surfaced in the coordinator registry and don’t repeat per worker.
55 56 57 58 |
# File 'lib/rigor/plugin/registry.rb', line 55 def self.materialize(blueprints:, services:) plugins = blueprints.map { |bp| bp.materialize(services: services) } new(plugins: plugins, blueprints: blueprints, load_errors: []) end |
Instance Method Details
#any_load_errors? ⇒ Boolean
73 74 75 |
# File 'lib/rigor/plugin/registry.rb', line 73 def any_load_errors? !load_errors.empty? end |
#empty? ⇒ Boolean
69 70 71 |
# File 'lib/rigor/plugin/registry.rb', line 69 def empty? plugins.empty? end |
#find(id) ⇒ Object
60 61 62 63 |
# File 'lib/rigor/plugin/registry.rb', line 60 def find(id) id_s = id.to_s plugins.find { |plugin| plugin.manifest.id == id_s } end |
#ids ⇒ Object
65 66 67 |
# File 'lib/rigor/plugin/registry.rb', line 65 def ids plugins.map { |plugin| plugin.manifest.id } end |
#type_node_resolvers ⇒ Object
ADR-13 slice 2 — flat ordered list of every loaded plugin’s manifest-declared TypeNodeResolver instances, in plugin registration order. Slice 3 wires this into the parser’s resolver chain; until then the method is a read-side aggregator only. The first non-nil ‘#resolve(node, scope)` return wins per ADR-13 WD3 / WD5 — registration order is the user’s lever.
84 85 86 |
# File 'lib/rigor/plugin/registry.rb', line 84 def type_node_resolvers plugins.flat_map { |plugin| plugin.manifest.type_node_resolvers } end |