iachat/enterprise/app/jobs/captain/lifecycle/dispatcher_job.rb
Rodribm10 d0d08ed662 feat(lifecycle): implement DispatcherJob
Replace no-op stub with full perform body: find delivery by id, skip if
blank, delegate to Captain::Lifecycle::Dispatcher#call. Add retry_on
with polynomially_longer backoff (3 attempts). Spec covers dispatcher
delegation and graceful skip for missing records.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-15 09:20:32 -03:00

18 lines
473 B
Ruby

# frozen_string_literal: true
class Captain::Lifecycle::DispatcherJob < ApplicationJob
queue_as :default
retry_on StandardError, wait: :polynomially_longer, attempts: 3
def self.perform_at(fire_at, delivery_id)
set(wait_until: fire_at).perform_later(delivery_id)
end
def perform(delivery_id)
delivery = Captain::Lifecycle::Delivery.find_by(id: delivery_id)
return if delivery.blank?
Captain::Lifecycle::Dispatcher.new(delivery).call
end
end