mirror of
https://github.com/internetee/registry.git
synced 2025-08-04 08:52:04 +02:00
Add sidekiq as a job backend
This commit is contained in:
parent
313731232e
commit
929ada8fd0
22 changed files with 109 additions and 154 deletions
|
@ -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
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class DomainExpireEmailJob < Que::Job
|
||||
class DomainExpireEmailJob < ApplicationJob
|
||||
def perform(domain_id, email)
|
||||
domain = Domain.find(domain_id)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1,4 +0,0 @@
|
|||
# To be able to remove existing jobs
|
||||
class QueJob < ApplicationRecord
|
||||
self.primary_key = 'job_id'
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue