Class: Webhookdb::Jobs::SyncTargetRunSync

Inherits:
Object
  • Object
show all
Extended by:
Async::Job
Includes:
Amigo::QueueBackoffJob
Defined in:
lib/webhookdb/jobs/sync_target_run_sync.rb

Instance Method Summary collapse

Methods included from Async::Job

extended

Instance Method Details

#dependent_queuesObject



12
13
14
# File 'lib/webhookdb/jobs/sync_target_run_sync.rb', line 12

def dependent_queues
  return ["critical"]
end

#perform(sync_target_id) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/webhookdb/jobs/sync_target_run_sync.rb', line 16

def perform(sync_target_id)
  stgt = Webhookdb::SyncTarget[sync_target_id]
  if stgt.nil?
    # A sync target may be enqueued, but destroyed before the sync runs.
    # If so, log a warning. We see this on staging a lot,
    # but it does happen on production too, and should be expected.
    self.logger.info("missing_sync_target", sync_target_id:)
    return
  end
  self.with_log_tags(
    sync_target_id: stgt.id,
    sync_target_connection_url: stgt.displaysafe_connection_url,
    sync_target_service_integration_service: stgt.service_integration.service_name,
    sync_target_service_integration_table: stgt.service_integration.table_name,
  ) do
    stgt.run_sync(now: Time.now)
  rescue Webhookdb::SyncTarget::SyncInProgress
    self.logger.info("sync_target_already_in_progress")
  rescue Webhookdb::SyncTarget::Deleted
    self.logger.info("sync_target_deleted")
  end
end