Class: Insika::Commands::ImportTools
- Inherits:
-
Object
- Object
- Insika::Commands::ImportTools
- Defined in:
- lib/insika/commands/import_tools.rb
Overview
BATCH ingestion of data-tools from a manifest (Phase 7, Step B).
Normalizes each tool (defaults + envelope adapter + endpoint→url + secret/
env) via ToolManifest, UPSERTs it into the ToolStore, and RELOADS the overlay +
catalog ONCE at the end — takes effect without a restart (NF3). Idempotent
(re-importing reconciles). Injects the deployment's {{secret.*}}/{{env.*}}
resolvers (D6/open-q2): the secret NEVER comes in the manifest.
ISOLATED PARTIAL FAILURE (R4): a malformed tool (invalid envelope, missing
endpoint, unconfigured secret, collision with a code tool, invalid url)
does NOT bring down the batch — it becomes an entry in errors[]. Only a STRUCTURAL error in the
manifest (defaults/tools of the wrong type) raises (transport -> 422).
Per-tool report in the shape of the Phase 6 pack importer.
-> { version, created: [names], updated: [names], errors: [tool,error] }
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(tool_store:, registry:, tool_catalog:, event_stream:, secrets: ENV, env: ENV) ⇒ ImportTools
constructor
A new instance of ImportTools.
Constructor Details
#initialize(tool_store:, registry:, tool_catalog:, event_stream:, secrets: ENV, env: ENV) ⇒ ImportTools
Returns a new instance of ImportTools.
21 22 23 24 25 26 27 28 |
# File 'lib/insika/commands/import_tools.rb', line 21 def initialize(tool_store:, registry:, tool_catalog:, event_stream:, secrets: ENV, env: ENV) @tool_store = tool_store @registry = registry @tool_catalog = tool_catalog @event_stream = event_stream @secrets = secrets @env = env end |
Instance Method Details
#call(command) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/insika/commands/import_tools.rb', line 30 def call(command) manifest = Insika::ToolManifest.from_h(command.payload) # structural -> 422 report = { version: manifest.version, created: [], updated: [], errors: [] } manifest.tools.each_with_index do |raw, i| import_one(manifest, raw, i, report) end reload_hot unless report[:created].empty? && report[:updated].empty? emit(report) report end |