Class: Sidekiq::Mcp::Tools::QueueDetailsTool

Inherits:
Sidekiq::Mcp::Tool show all
Defined in:
lib/sidekiq/mcp/tools/queue_details_tool.rb

Instance Method Summary collapse

Methods inherited from Sidekiq::Mcp::Tool

arguments, #call, description, schema_to_json_schema, to_tool_definition

Instance Method Details

#perform(queue_name:, limit: 10) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/sidekiq/mcp/tools/queue_details_tool.rb', line 17

def perform(queue_name:, limit: 10)
  queue = Sidekiq::Queue.new(queue_name)
  jobs = queue.first(limit).map do |job|
    {
      jid: job.jid,
      class: job.klass,
      args: job.args,
      created_at: job.created_at,
      enqueued_at: job.enqueued_at,
      queue: job.queue
    }
  end
  
  {
    queue_name: queue_name,
    size: queue.size,
    latency: queue.latency,
    jobs: jobs
  }.to_json
end