Class: CollavreLinear::OutboundSyncJob

Inherits:
ApplicationJob
  • Object
show all
Defined in:
app/jobs/collavre_linear/outbound_sync_job.rb

Overview

Enqueues an outbound sync for a single Creative to Linear.

Usage:

CollavreLinear::OutboundSyncJob.perform_later(creative.id)

The critical section is guarded with a row-level lock on the IssueLink (or the ProjectLink's creative row when no IssueLink exists yet) so concurrent performs cannot double-create issues.

Instance Method Summary collapse

Instance Method Details

#perform(creative_id) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'app/jobs/collavre_linear/outbound_sync_job.rb', line 25

def perform(creative_id)
  creative = ::Collavre::Creative.find(creative_id)

  # Resolve an existing IssueLink (or the creative itself) to lock on.
  # We lock the creative row so concurrent jobs serialize without racing to
  # create duplicate IssueLinks.
  creative.with_lock do
    CollavreLinear::CreativeExporter.new(creative).sync!
  end
rescue ActiveRecord::RecordNotFound
  # Creative was deleted — nothing to sync.
  Rails.logger.info("[CollavreLinear::OutboundSyncJob] Creative #{creative_id} not found; skipping")
end