Class: Insika::Commands::DeleteMcp
- Inherits:
-
Object
- Object
- Insika::Commands::DeleteMcp
- Defined in:
- lib/insika/commands/delete_mcp.rb
Overview
Control command: removes an MCP instance from the
McpStore. Idempotent (existed: false if there was none). -> { existed: bool }.
Instance Method Summary collapse
- #call(command) ⇒ Object
-
#initialize(mcp_store:, event_stream:) ⇒ DeleteMcp
constructor
A new instance of DeleteMcp.
Constructor Details
#initialize(mcp_store:, event_stream:) ⇒ DeleteMcp
Returns a new instance of DeleteMcp.
10 11 12 13 |
# File 'lib/insika/commands/delete_mcp.rb', line 10 def initialize(mcp_store:, event_stream:) @mcp_store = mcp_store @event_stream = event_stream end |
Instance Method Details
#call(command) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/insika/commands/delete_mcp.rb', line 15 def call(command) p = AgentPayload.symbolize(command.payload) name = AgentPayload.presence(p[:name]) raise Insika::ValidationError, "name is required" if name.nil? existed = @mcp_store.delete(name) @event_stream.emit(Insika::Event.new( type: :mcp_deleted, data: { name: name, existed: existed }, meta: { at: Time.now.utc.iso8601 } )) { existed: existed } end |