Skip to content

Commit f50f3e1

Browse files
committed
Use Sidekiq for PDS jobs
This updates the PDS jobs to use Sidekiq as their queue adapter rather than Good Job as we think the performance will be better.
1 parent 7f3a1f5 commit f50f3e1

File tree

4 files changed

+28
-12
lines changed

4 files changed

+28
-12
lines changed
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# frozen_string_literal: true
2+
3+
module NHSAPIConcurrencyConcernSidekiq
4+
extend ActiveSupport::Concern
5+
6+
include Sidekiq::Job
7+
include Sidekiq::Throttled::Job
8+
9+
included do
10+
self.queue_adapter = :sidekiq unless Rails.env.test?
11+
12+
queue_as :pds
13+
14+
sidekiq_throttle_as :pds
15+
16+
retry_on Faraday::ServerError, wait: :polynomially_longer
17+
end
18+
end

app/jobs/patient_nhs_number_lookup_job.rb

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

33
class PatientNHSNumberLookupJob < ApplicationJob
4-
def self.concurrent_jobs_per_second = 5
5-
def self.concurrency_key = :pds
6-
7-
include NHSAPIConcurrencyConcernGoodJob
8-
9-
queue_as :imports
4+
include NHSAPIConcurrencyConcernSidekiq
105

116
def perform(patient)
127
return if patient.nhs_number.present? && !patient.invalidated?

app/jobs/patient_update_from_pds_job.rb

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

33
class PatientUpdateFromPDSJob < ApplicationJob
4-
def self.concurrent_jobs_per_second = 5
5-
def self.concurrency_key = :pds
6-
7-
include NHSAPIConcurrencyConcernGoodJob
8-
9-
queue_as :pds
4+
include NHSAPIConcurrencyConcernSidekiq
105

116
def perform(patient)
127
raise MissingNHSNumber if patient.nhs_number.nil?

config/initializers/sidekiq.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,11 @@
1717
config.cooldown_period = 1.0
1818
config.cooldown_threshold = 2000
1919
end
20+
21+
Sidekiq::Throttled::Registry.add(
22+
:pds,
23+
threshold: {
24+
limit: 5,
25+
period: 1.second
26+
}
27+
)

0 commit comments

Comments
 (0)