Class: LlmLogs::Batch::PollJob

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
app/jobs/llm_logs/batch/poll_job.rb

Constant Summary collapse

STALE_CLAIM_AFTER =

A placeholder claim (status “pending”, no openai_batch_id) is only meant to exist for the sub-second window of Submitter#submit. Anything older died mid-submit (e.g. the worker was killed), so its requests are stranded. Recover them.

15.minutes

Instance Method Summary collapse

Instance Method Details

#performObject



11
12
13
14
15
16
17
18
# File 'app/jobs/llm_logs/batch/poll_job.rb', line 11

def perform
  recover_stale_claims
  LlmLogs::Batch.unreconciled.where.not(openai_batch_id: nil).find_each do |batch|
    batch.reconcile!
  rescue StandardError => e
    Rails.logger.error("[llm_logs] batch #{batch.id} reconcile failed: #{e.class}: #{e.message}")
  end
end