Class: Sidekiq::Mcp::Tools::FailedJobsTool

Inherits:
Sidekiq::Mcp::Tool show all
Defined in:
lib/sidekiq/mcp/tools/failed_jobs_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(limit: 10) ⇒ Object



16
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/failed_jobs_tool.rb', line 16

def perform(limit: 10)
  failed_set = Sidekiq::RetrySet.new
  jobs = failed_set.first(limit).map do |job|
    {
      jid: job.jid,
      class: job.klass,
      args: job.args,
      queue: job.queue,
      error_message: job["error_message"],
      error_class: job["error_class"],
      failed_at: job["failed_at"],
      retry_count: job["retry_count"],
      retried_at: job["retried_at"]
    }
  end
  
  {
    total_size: failed_set.size,
    jobs: jobs
  }.to_json
end