Class: Webhookdb::Jobs::Backfill
- Inherits:
-
Object
- Object
- Webhookdb::Jobs::Backfill
- Extended by:
- Async::Job
- Includes:
- Amigo::DurableJob, Amigo::QueueBackoffJob
- Defined in:
- lib/webhookdb/jobs/backfill.rb
Instance Method Summary collapse
-
#_perform(event) ⇒ Object
This is really the lowest-priority job so always defer to other queues.
Methods included from Async::Job
Methods included from Amigo::DurableJob
enabled?, ensure_jobs_tables, heartbeat, heartbeat!, included, insert_job, lock_job, poll_jobs, reconnect, replace_database_settings, set_database_setting, storage_datasets, unlock_job
Instance Method Details
#_perform(event) ⇒ Object
This is really the lowest-priority job so always defer to other queues.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/webhookdb/jobs/backfill.rb', line 18 def _perform(event) begin bfjob = self.lookup_model(Webhookdb::BackfillJob, event.payload) rescue RuntimeError => e self.(result: "skipped_missing_backfill_job", exception: e) return end sint = bfjob.service_integration bflock = bfjob.ensure_service_integration_lock self.(sint..merge(backfill_job_id: bfjob.opaque_id)) sint.db.transaction do unless bflock.lock? self.(result: "skipped_locked_backfill_job") bfjob.update(finished_at: Time.now) break end bfjob.refresh if bfjob.finished? self.(result: "skipped_finished_backfill_job") break end begin sint.replicator.backfill(bfjob) rescue Webhookdb::Replicator::CredentialsMissing # The credentials could have been cleared out, so just finish this job. self.(result: "skipped_backfill_job_without_credentials") bfjob.update(finished_at: Time.now) break end end end |