Class: Pgbus::MCP::Tools::DlqDetailTool
- Defined in:
- lib/pgbus/mcp/tools/dlq_detail_tool.rb
Overview
Inspect a single dead-letter message. Maps to DataSource#job_detail against the named DLQ queue when queue is supplied; falls back to a cross-DLQ scan via DataSource#dlq_message_detail when it is not. Payload redacted by default.
Class Method Summary collapse
-
.ambiguity_check(data_source, msg_id) ⇒ Object
When the caller didn’t specify a queue, scan every DLQ for the id and refuse to guess if more than one matches.
- .call(msg_id:, queue: nil, include_payloads: false, server_context: nil) ⇒ Object
Methods inherited from BaseTool
annotations_value, data_source_from, error_response, json_response, payloads_allowed?
Class Method Details
.ambiguity_check(data_source, msg_id) ⇒ Object
When the caller didn’t specify a queue, scan every DLQ for the id and refuse to guess if more than one matches. Returns an error response on ambiguity, nil otherwise (so the caller proceeds with the normal first-match lookup).
58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/pgbus/mcp/tools/dlq_detail_tool.rb', line 58 def self.ambiguity_check(data_source, msg_id) dlq_suffix = Pgbus::DEAD_LETTER_SUFFIX dlqs = data_source.queues_with_metrics.select { |q| q[:name].to_s.end_with?(dlq_suffix) } matches = dlqs.map { |q| q[:name] }.select { |name| data_source.job_detail(name, msg_id) } return nil if matches.size <= 1 error_response( "Dead-letter message #{msg_id} is ambiguous — present in #{matches.size} DLQs " \ "(#{matches.join(", ")}). Pass `queue:` to disambiguate." ) end |
.call(msg_id:, queue: nil, include_payloads: false, server_context: nil) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/pgbus/mcp/tools/dlq_detail_tool.rb', line 40 def self.call(msg_id:, queue: nil, include_payloads: false, server_context: nil) data_source = data_source_from(server_context) detail = if queue data_source.job_detail(queue, msg_id) else ambiguity_check(data_source, msg_id) || data_source.(msg_id) end return error_response("Dead-letter message #{msg_id} not found") unless detail return detail if detail.is_a?(::MCP::Tool::Response) json_response({ message: detail }, server_context: server_context, include_payloads: include_payloads) end |