21
1
Fork 0
mirror of https://github.com/Evolix/chexpire.git synced 2024-04-29 23:40:49 +02:00
chexpire/app/jobs/resync_job.rb
Colin Darie 717cd3fac3
Wrap first sync in a common job
Sometimes, when the first job is executed milliseconds after the insert, 
the db would not return it.
This way, we can safely perform another attempt.
2018-07-05 17:54:21 +02:00

19 lines
512 B
Ruby

class ResyncJob < ApplicationJob
queue_as :default
rescue_from ActiveRecord::RecordNotFound do
raise if attempt_number == 5 # rubocop:disable Style/SignalException
# at job creation, the db could not return immediately the check
# we have to wait a few (milli)-seconds
retry_job(wait: attempt_number**2)
end
def perform(check_id)
check = Check.find(check_id)
WhoisSyncJob.perform_later(check_id) if check.domain?
SSLSyncJob.perform_later(check_id) if check.ssl?
end
end