Add sidekiq as a job backend

This commit is contained in:
Alex Sherman 2021-03-03 16:37:33 +05:00
parent 313731232e
commit 929ada8fd0
22 changed files with 109 additions and 154 deletions

View file

@ -14,7 +14,7 @@ module Domains
return unless saved
recipients.each do |recipient|
DomainExpireEmailJob.enqueue(domain.id, recipient, run_at: send_time)
DomainExpireEmailJob.set(wait_until: send_time).perform_later(domain.id, recipient)
end
end

View file

@ -1,4 +1,4 @@
class DomainExpireEmailJob < Que::Job
class DomainExpireEmailJob < ApplicationJob
def perform(domain_id, email)
domain = Domain.find(domain_id)

View file

@ -12,7 +12,8 @@ class RegistrantChangeExpiredEmailJob < ApplicationJob
private
def log(domain)
message = "Send RegistrantChangeMailer#expired email for domain #{domain.name} (##{domain.id}) to #{domain.new_registrant_email}"
message = 'Send RegistrantChangeMailer#expired email for domain '\
"#{domain.name} (##{domain.id}) to #{domain.new_registrant_email}"
logger.info(message)
end

View file

@ -19,8 +19,12 @@ module Domain::Deletable
end
def do_not_delete_later
# Que job can be manually deleted in admin area UI
QueJob.find_by("args->>0 = '#{id}'", job_class: DomainDeleteJob.name)&.destroy
return if Rails.env.test?
jobs = Sidekiq::ScheduledSet.new.select do |job|
job.args.first['job_class'] == 'DomainDeleteJob' && job.args.first['arguments'] == [id]
end
jobs.each(&:delete)
end
def deletion_time_span

View file

@ -1,4 +0,0 @@
# To be able to remove existing jobs
class QueJob < ApplicationRecord
self.primary_key = 'job_id'
end