Skip to content

Commit b11669b

Browse files
committed
Refactor ApplicationJob
This refactors the `ApplicationJob` in to two variants, `ApplicationJobActiveJob and `ApplicationJobSidekiq`, according to how the job is defined. We're making this change to support migrating away from using Active Job and instead using the Sidekiq API directly, which gives us a number of benefits. We can't just switch over in one go, as any Active Job jobs left in the queue will fail to run once the job class has been converted. So instead, we need two versions of each job, and then only once we no longer have any Active Job jobs in the queue, we can remove the Active Job variations. Jira-Issue: MAV-7288
1 parent e00291c commit b11669b

44 files changed

Lines changed: 54 additions & 66 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/jobs/application_job.rb

Lines changed: 0 additions & 8 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
# rubocop:disable Rails/ApplicationJob
4+
class ApplicationJobActiveJob < ActiveJob::Base
5+
discard_on ActiveJob::DeserializationError
6+
end
7+
# rubocop:enable Rails/ApplicationJob
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# frozen_string_literal: true
2+
3+
class ApplicationJobSidekiq
4+
include Sidekiq::Job
5+
end

app/jobs/bulk_remove_parent_relationships_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class BulkRemoveParentRelationshipsJob < ApplicationJob
3+
class BulkRemoveParentRelationshipsJob < ApplicationJobActiveJob
44
queue_as :imports
55

66
def perform(

app/jobs/commit_patient_changesets_job.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
# frozen_string_literal: true
22

3-
class CommitPatientChangesetsJob
4-
include Sidekiq::Job
5-
include Sidekiq::Throttled::Job
3+
class CommitPatientChangesetsJob < ApplicationJobSidekiq
64
include PatientImportConcern
75

8-
queue_as :imports
6+
sidekiq_options queue: :imports
97

108
def perform(patient_changeset_ids)
119
changesets =

app/jobs/enqueue_automated_careplus_reports_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class EnqueueAutomatedCareplusReportsJob < ApplicationJob
3+
class EnqueueAutomatedCareplusReportsJob < ApplicationJobActiveJob
44
queue_as :careplus
55

66
def perform

app/jobs/enqueue_location_position_updater_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class EnqueueLocationPositionUpdaterJob < ApplicationJob
3+
class EnqueueLocationPositionUpdaterJob < ApplicationJobActiveJob
44
queue_as :third_party_data_imports
55

66
def perform

app/jobs/enqueue_patients_aged_out_of_schools_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class EnqueuePatientsAgedOutOfSchoolsJob < ApplicationJob
3+
class EnqueuePatientsAgedOutOfSchoolsJob < ApplicationJobActiveJob
44
queue_as :patients
55

66
def perform

app/jobs/enqueue_process_unmatched_consent_forms_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class EnqueueProcessUnmatchedConsentFormsJob < ApplicationJob
3+
class EnqueueProcessUnmatchedConsentFormsJob < ApplicationJobActiveJob
44
include SingleConcurrencyConcern
55

66
queue_as :consents

app/jobs/enqueue_school_consent_reminders_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# frozen_string_literal: true
22

3-
class EnqueueSchoolConsentRemindersJob < ApplicationJob
3+
class EnqueueSchoolConsentRemindersJob < ApplicationJobActiveJob
44
queue_as :notifications
55

66
def perform

0 commit comments

Comments
 (0)