Class: Igniter::Store::SchemaGraph
- Inherits:
-
Object
- Object
- Igniter::Store::SchemaGraph
- Defined in:
- lib/igniter/store/schema_graph.rb
Instance Method Summary collapse
- #command_snapshot ⇒ Object
- #consumers_for(store) ⇒ Object
-
#derivation_snapshot ⇒ Object
Compact snapshot of registered derivation rules (rule callables omitted).
-
#derivations_for_store(store:) ⇒ Object
All derivation rules whose source_store matches the given store.
-
#descriptor_snapshot ⇒ Object
Snapshot of all raw protocol-level descriptors registered via OP1.
- #effect_snapshot ⇒ Object
-
#initialize ⇒ SchemaGraph
constructor
A new instance of SchemaGraph.
-
#metadata_snapshot ⇒ Object
Returns a compact snapshot of all registered access paths keyed by store.
- #path_for(store:, scope:) ⇒ Object
- #paths_for(store) ⇒ Object
- #projection_for(name:) ⇒ Object
-
#projection_snapshot ⇒ Object
Compact snapshot of all registered projections, keyed by name.
-
#projections_for_store(store:) ⇒ Object
All projections whose reads list includes the given store.
- #register(path) ⇒ Object
- #register_command_descriptor(descriptor) ⇒ Object
-
#register_derivation(derivation_rule) ⇒ Object
— Derivation registry —.
- #register_effect_descriptor(descriptor) ⇒ Object
- #register_history_descriptor(descriptor) ⇒ Object
-
#register_projection(projection_path) ⇒ Object
— Projection registry —.
-
#register_relation(relation_rule) ⇒ Object
— Relation registry —.
-
#register_retention(store, policy) ⇒ Object
— Retention registry —.
-
#register_scatter(scatter_rule) ⇒ Object
— Scatter Derivation registry —.
-
#register_store_descriptor(descriptor) ⇒ Object
— Raw descriptor storage (OP2 — metadata export) —.
- #register_subscription_descriptor(descriptor) ⇒ Object
- #registered_relations ⇒ Object
- #registered_stores ⇒ Object
- #relation_for(name:) ⇒ Object
-
#relation_snapshot ⇒ Object
Compact snapshot of all registered relations (no callables — pure metadata).
-
#retention_for(store:) ⇒ Object
Returns the RetentionPolicy for store, or nil (meaning :permanent / no compaction).
-
#retention_snapshot ⇒ Object
Compact snapshot of all registered retention policies.
-
#retention_stores ⇒ Object
Stores with an explicitly registered retention policy (any strategy).
-
#scatter_snapshot ⇒ Object
Compact snapshot of registered scatter rules (rule callables omitted).
-
#scatters_for_store(store:) ⇒ Object
All scatter rules whose source_store matches the given store.
Constructor Details
#initialize ⇒ SchemaGraph
Returns a new instance of SchemaGraph.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/igniter/store/schema_graph.rb', line 6 def initialize @paths = Hash.new { |hash, key| hash[key] = [] } @projections = {} @derivations = [] @scatters = [] @relations = {} @retention = {} # Raw protocol descriptor storage (OP2 — metadata export) @store_descriptors = {} @history_descriptors = {} @command_descriptors = {} @effect_descriptors = {} @subscription_descriptors = {} end |
Instance Method Details
#command_snapshot ⇒ Object
208 209 210 |
# File 'lib/igniter/store/schema_graph.rb', line 208 def command_snapshot @command_descriptors end |
#consumers_for(store) ⇒ Object
30 31 32 |
# File 'lib/igniter/store/schema_graph.rb', line 30 def consumers_for(store) @paths[store].flat_map { |path| path.consumers.to_a }.uniq end |
#derivation_snapshot ⇒ Object
Compact snapshot of registered derivation rules (rule callables omitted).
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/igniter/store/schema_graph.rb', line 87 def derivation_snapshot @derivations.map.with_index do |r, i| { index: i, source_store: r.source_store, source_filters: r.source_filters, target_store: r.target_store, target_key: r.target_key.respond_to?(:call) ? :callable : r.target_key, has_rule: true } end end |
#derivations_for_store(store:) ⇒ Object
All derivation rules whose source_store matches the given store.
82 83 84 |
# File 'lib/igniter/store/schema_graph.rb', line 82 def derivations_for_store(store:) @derivations.select { |r| r.source_store == store } end |
#descriptor_snapshot ⇒ Object
Snapshot of all raw protocol-level descriptors registered via OP1.
217 218 219 220 221 222 223 224 225 |
# File 'lib/igniter/store/schema_graph.rb', line 217 def descriptor_snapshot { stores: @store_descriptors, histories: @history_descriptors, commands: @command_descriptors, effects: @effect_descriptors, subscriptions: @subscription_descriptors } end |
#effect_snapshot ⇒ Object
212 213 214 |
# File 'lib/igniter/store/schema_graph.rb', line 212 def effect_snapshot @effect_descriptors end |
#metadata_snapshot ⇒ Object
Returns a compact snapshot of all registered access paths keyed by store. Each entry describes how the engine routes scope queries for that store: scope name, lookup strategy, active filters, cache TTL, and consumer count. Index descriptors (which fields are co-indexed) remain manifest/facade metadata — they are a schema contract, not an engine routing concern.
232 233 234 235 236 237 238 239 240 241 242 243 244 245 |
# File 'lib/igniter/store/schema_graph.rb', line 232 def @paths.each_with_object({}) do |(store, paths), snapshot| snapshot[store] = paths.map do |path| { store: path.store, scope: path.scope, lookup: path.lookup, filters: path.filters, cache_ttl: path.cache_ttl, consumer_count: path.consumers.to_a.size } end end end |
#path_for(store:, scope:) ⇒ Object
34 35 36 |
# File 'lib/igniter/store/schema_graph.rb', line 34 def path_for(store:, scope:) @paths[store].find { |path| path.scope == scope } end |
#paths_for(store) ⇒ Object
26 27 28 |
# File 'lib/igniter/store/schema_graph.rb', line 26 def paths_for(store) @paths[store].dup end |
#projection_for(name:) ⇒ Object
49 50 51 |
# File 'lib/igniter/store/schema_graph.rb', line 49 def projection_for(name:) @projections[name] end |
#projection_snapshot ⇒ Object
Compact snapshot of all registered projections, keyed by name. Parallel to metadata_snapshot for access paths.
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/igniter/store/schema_graph.rb', line 60 def projection_snapshot @projections.transform_values do |p| { name: p.name, reads: p.reads, relations: p.relations, consumer_hint: p.consumer_hint, reactive: p.reactive, store_count: p.reads.size, relation_count: p.relations.size } end end |
#projections_for_store(store:) ⇒ Object
All projections whose reads list includes the given store.
54 55 56 |
# File 'lib/igniter/store/schema_graph.rb', line 54 def projections_for_store(store:) @projections.values.select { |p| p.reads.include?(store) } end |
#register(path) ⇒ Object
21 22 23 24 |
# File 'lib/igniter/store/schema_graph.rb', line 21 def register(path) @paths[path.store] << path self end |
#register_command_descriptor(descriptor) ⇒ Object
192 193 194 195 196 197 198 |
# File 'lib/igniter/store/schema_graph.rb', line 192 def register_command_descriptor(descriptor) owner = descriptor[:owner].to_sym name = descriptor[:name].to_sym @command_descriptors[owner] ||= {} @command_descriptors[owner][name] = descriptor self end |
#register_derivation(derivation_rule) ⇒ Object
— Derivation registry —
76 77 78 79 |
# File 'lib/igniter/store/schema_graph.rb', line 76 def register_derivation(derivation_rule) @derivations << derivation_rule self end |
#register_effect_descriptor(descriptor) ⇒ Object
200 201 202 203 204 205 206 |
# File 'lib/igniter/store/schema_graph.rb', line 200 def register_effect_descriptor(descriptor) owner = descriptor[:owner].to_sym name = descriptor[:name].to_sym @effect_descriptors[owner] ||= {} @effect_descriptors[owner][name] = descriptor self end |
#register_history_descriptor(descriptor) ⇒ Object
182 183 184 185 |
# File 'lib/igniter/store/schema_graph.rb', line 182 def register_history_descriptor(descriptor) @history_descriptors[descriptor[:name].to_sym] = descriptor self end |
#register_projection(projection_path) ⇒ Object
— Projection registry —
44 45 46 47 |
# File 'lib/igniter/store/schema_graph.rb', line 44 def register_projection(projection_path) @projections[projection_path.name] = projection_path self end |
#register_relation(relation_rule) ⇒ Object
— Relation registry —
127 128 129 130 |
# File 'lib/igniter/store/schema_graph.rb', line 127 def register_relation(relation_rule) @relations[relation_rule.name] = relation_rule self end |
#register_retention(store, policy) ⇒ Object
— Retention registry —
155 156 157 158 |
# File 'lib/igniter/store/schema_graph.rb', line 155 def register_retention(store, policy) @retention[store] = policy self end |
#register_scatter(scatter_rule) ⇒ Object
— Scatter Derivation registry —
102 103 104 105 |
# File 'lib/igniter/store/schema_graph.rb', line 102 def register_scatter(scatter_rule) @scatters << scatter_rule self end |
#register_store_descriptor(descriptor) ⇒ Object
— Raw descriptor storage (OP2 — metadata export) —
177 178 179 180 |
# File 'lib/igniter/store/schema_graph.rb', line 177 def register_store_descriptor(descriptor) @store_descriptors[descriptor[:name].to_sym] = descriptor self end |
#register_subscription_descriptor(descriptor) ⇒ Object
187 188 189 190 |
# File 'lib/igniter/store/schema_graph.rb', line 187 def register_subscription_descriptor(descriptor) @subscription_descriptors[descriptor[:name].to_sym] = descriptor self end |
#registered_relations ⇒ Object
136 137 138 |
# File 'lib/igniter/store/schema_graph.rb', line 136 def registered_relations @relations.keys end |
#registered_stores ⇒ Object
38 39 40 |
# File 'lib/igniter/store/schema_graph.rb', line 38 def registered_stores @paths.keys end |
#relation_for(name:) ⇒ Object
132 133 134 |
# File 'lib/igniter/store/schema_graph.rb', line 132 def relation_for(name:) @relations[name] end |
#relation_snapshot ⇒ Object
Compact snapshot of all registered relations (no callables — pure metadata).
141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/igniter/store/schema_graph.rb', line 141 def relation_snapshot @relations.transform_values do |r| { name: r.name, source: r.source, partition: r.partition, target: r.target, index_store: :"__rel_#{r.name}" } end end |
#retention_for(store:) ⇒ Object
Returns the RetentionPolicy for store, or nil (meaning :permanent / no compaction).
161 162 163 |
# File 'lib/igniter/store/schema_graph.rb', line 161 def retention_for(store:) @retention[store] end |
#retention_snapshot ⇒ Object
Compact snapshot of all registered retention policies.
171 172 173 |
# File 'lib/igniter/store/schema_graph.rb', line 171 def retention_snapshot @retention.transform_values { |p| { strategy: p.strategy, duration: p.duration } } end |
#retention_stores ⇒ Object
Stores with an explicitly registered retention policy (any strategy).
166 167 168 |
# File 'lib/igniter/store/schema_graph.rb', line 166 def retention_stores @retention.keys end |
#scatter_snapshot ⇒ Object
Compact snapshot of registered scatter rules (rule callables omitted).
113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/igniter/store/schema_graph.rb', line 113 def scatter_snapshot @scatters.map.with_index do |r, i| { index: i, source_store: r.source_store, partition_by: r.partition_by, target_store: r.target_store, has_rule: true } end end |
#scatters_for_store(store:) ⇒ Object
All scatter rules whose source_store matches the given store.
108 109 110 |
# File 'lib/igniter/store/schema_graph.rb', line 108 def scatters_for_store(store:) @scatters.select { |r| r.source_store == store } end |