Merge pull request #10906 from mfo/US/reword-queueing
amelioration : ETQ operateur j'aimerais simplifier/optimiser la gestion des tâches asynchrones
This commit is contained in:
commit
fc37bbaa4a
21 changed files with 28 additions and 29 deletions
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BatchOperationEnqueueAllJob < ApplicationJob
|
||||
queue_as :mailers # hotfix
|
||||
queue_as :critical
|
||||
|
||||
def perform(batch_operation)
|
||||
batch_operation.enqueue_all
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class BatchOperationProcessOneJob < ApplicationJob
|
||||
queue_as :mailers # hotfix
|
||||
queue_as :critical
|
||||
retry_on StandardError, attempts: 1 # default 5, for now no retryable behavior
|
||||
|
||||
def perform(batch_operation, dossier)
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
class ChampFetchExternalDataJob < ApplicationJob
|
||||
discard_on ActiveJob::DeserializationError
|
||||
queue_as :critical # ui feedback, asap
|
||||
|
||||
include Dry::Monads[:result]
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Cron::CronJob < ApplicationJob
|
||||
queue_as :cron
|
||||
queue_as :default
|
||||
class_attribute :schedule_expression
|
||||
|
||||
class << self
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
class DestroyRecordLaterJob < ApplicationJob
|
||||
discard_on ActiveRecord::RecordNotFound
|
||||
queue_as :low # destroy later, will be done when possible
|
||||
|
||||
def perform(record)
|
||||
record.destroy
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
class DolistReportJob < ApplicationJob
|
||||
# Consolidate random recent emails dispatched to Dolist with their statuses
|
||||
# and send a report by email.
|
||||
queue_as :low # reporting will be done asap
|
||||
def perform(report_to, sample_size = 1000)
|
||||
events = EmailEvent.dolist.dispatched.where(processed_at: 2.weeks.ago..).order("RANDOM()").limit(sample_size)
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DossierIndexSearchTermsJob < ApplicationJob
|
||||
queue_as :low_priority
|
||||
queue_as :low
|
||||
|
||||
discard_on ActiveRecord::RecordNotFound
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DossierOperationLogMoveToColdStorageBatchJob < ApplicationJob
|
||||
queue_as :low_priority
|
||||
queue_as :low
|
||||
|
||||
def perform(ids)
|
||||
DossierOperationLog.where(id: ids)
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class DossierRebaseJob < ApplicationJob
|
||||
queue_as :low_priority # they are massively enqueued, so don't interfere with others especially antivirus
|
||||
queue_as :low # they are massively enqueued, so don't interfere with others especially antivirus
|
||||
|
||||
# If by the time the job runs the Dossier has been deleted, ignore the rebase
|
||||
discard_on ActiveRecord::RecordNotFound
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class EtablissementUpdateJob < ApplicationJob
|
||||
queue_as :critical # reporting will be done asap, but no occurence found. maube dead?
|
||||
def perform(dossier, siret)
|
||||
begin
|
||||
etablissement_attributes = APIEntrepriseService.get_etablissement_params_for_siret(siret, dossier.procedure.id)
|
||||
|
|
|
@ -1,8 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class HelpscoutCreateConversationJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
queue_as :critical # user feedback is critical
|
||||
class FileNotScannedYetError < StandardError
|
||||
end
|
||||
|
||||
|
|
|
@ -13,6 +13,6 @@ class PriorizedMailDeliveryJob < ActionMailer::MailDeliveryJob
|
|||
end
|
||||
|
||||
def custom_queue
|
||||
ENV.fetch('BULK_EMAIL_QUEUE') { Rails.application.config.action_mailer.deliver_later_queue_name.to_s }
|
||||
'low'
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProcedureSVASVRProcessDossierJob < ApplicationJob
|
||||
queue_as :sva
|
||||
queue_as :critical
|
||||
|
||||
def perform(dossier)
|
||||
dossier.process_sva_svr!
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ProcessStalledDeclarativeDossierJob < ApplicationJob
|
||||
queue_as :low
|
||||
def perform(dossier)
|
||||
return if dossier.declarative_triggered_at.present?
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class ResetExpiringDossiersJob < ApplicationJob
|
||||
queue_as :low
|
||||
def perform(procedure)
|
||||
procedure
|
||||
.dossiers
|
||||
|
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SendClosingNotificationJob < ApplicationJob
|
||||
queue_as :low # no rush on this one
|
||||
|
||||
def perform(user_ids, content, procedure)
|
||||
User.where(id: user_ids).find_each do |user|
|
||||
Expired::MailRateLimiter.new().send_with_delay(UserMailer.notify_after_closing(user, content, @procedure))
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class WebHookJob < ApplicationJob
|
||||
queue_as :webhooks_v1
|
||||
queue_as :default
|
||||
|
||||
TIMEOUT = 10
|
||||
|
||||
|
|
|
@ -54,14 +54,14 @@ module TPS
|
|||
config.action_dispatch.ip_spoofing_check = false
|
||||
|
||||
# Set the queue name for the mail delivery jobs to 'mailers'
|
||||
config.action_mailer.deliver_later_queue_name = 'mailers'
|
||||
config.action_mailer.deliver_later_queue_name = 'critical' # otherwise, :low
|
||||
|
||||
# Allow the error messages format to be customized
|
||||
config.active_model.i18n_customize_full_message = true
|
||||
|
||||
# Set the queue name for the analysis jobs to 'active_storage_analysis'
|
||||
config.active_storage.queues.analysis = :active_storage_analysis
|
||||
config.active_storage.queues.purge = :purge
|
||||
config.active_storage.queues.analysis = :default
|
||||
config.active_storage.queues.purge = :low
|
||||
|
||||
config.active_support.cache_format_version = 7.0
|
||||
|
||||
|
|
|
@ -11,8 +11,7 @@ RSpec.describe AdministrateurMailer, type: :mailer do
|
|||
it { expect(subject.subject).to include("La suppression automatique des dossiers a été activée sur la démarche") }
|
||||
|
||||
context 'when perform_later is called' do
|
||||
let(:custom_queue) { 'low_priority' }
|
||||
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
|
||||
let(:custom_queue) { 'low' }
|
||||
it 'enqueues email is custom queue for low priority delivery' do
|
||||
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
|
||||
end
|
||||
|
@ -52,8 +51,7 @@ end
|
|||
it { expect(subject.body).to include("un de vos services n'a pas son siret renseigné") }
|
||||
|
||||
context 'when perform_later is called' do
|
||||
let(:custom_queue) { 'low_priority' }
|
||||
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
|
||||
let(:custom_queue) { 'low' }
|
||||
it 'enqueues email is custom queue for low priority delivery' do
|
||||
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
|
||||
end
|
||||
|
|
|
@ -10,8 +10,7 @@ RSpec.describe InstructeurMailer, type: :mailer do
|
|||
it { expect(subject.body).to include('Bonjour') }
|
||||
|
||||
context 'when perform_later is called' do
|
||||
let(:custom_queue) { 'low_priority' }
|
||||
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
|
||||
let(:custom_queue) { 'low' }
|
||||
|
||||
it 'enqueues email is custom queue for low priority delivery' do
|
||||
expect { subject.deliver_later }.to have_enqueued_job(PriorizedMailDeliveryJob).on_queue(custom_queue)
|
||||
|
@ -81,9 +80,7 @@ RSpec.describe InstructeurMailer, type: :mailer do
|
|||
end
|
||||
|
||||
context 'when perform_later is called' do
|
||||
let(:custom_queue) { 'low_priority' }
|
||||
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
|
||||
|
||||
let(:custom_queue) { 'low' }
|
||||
it 'enqueues email is custom queue for low priority delivery' do
|
||||
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
|
||||
end
|
||||
|
|
|
@ -151,8 +151,7 @@ RSpec.describe UserMailer, type: :mailer do
|
|||
|
||||
context 'when perform_later is called' do
|
||||
let(:role) { administrateurs(:default_admin) }
|
||||
let(:custom_queue) { 'low_priority' }
|
||||
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
|
||||
let(:custom_queue) { 'low' }
|
||||
it 'enqueues email is custom queue for low priority delivery' do
|
||||
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
|
||||
end
|
||||
|
@ -168,8 +167,7 @@ RSpec.describe UserMailer, type: :mailer do
|
|||
end
|
||||
|
||||
context 'when perform_later is called' do
|
||||
let(:custom_queue) { 'low_priority' }
|
||||
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
|
||||
let(:custom_queue) { 'low' }
|
||||
it 'enqueues email is custom queue for low priority delivery' do
|
||||
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
|
||||
end
|
||||
|
@ -188,8 +186,7 @@ RSpec.describe UserMailer, type: :mailer do
|
|||
end
|
||||
|
||||
context 'when perform_later is called' do
|
||||
let(:custom_queue) { 'low_priority' }
|
||||
before { ENV['BULK_EMAIL_QUEUE'] = custom_queue }
|
||||
let(:custom_queue) { 'low' }
|
||||
it 'enqueues email is custom queue for low priority delivery' do
|
||||
expect { subject.deliver_later }.to have_enqueued_job.on_queue(custom_queue)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue