Class: KmsKeyRotation::RotateKeysJob

Inherits:
Object
  • Object
show all
Includes:
Sidekiq::Worker
Defined in:
app/sidekiq/kms_key_rotation/rotate_keys_job.rb

Instance Method Summary collapse

Instance Method Details

#perform(gids) ⇒ Object



9
10
11
12
13
14
15
16
17
18
19
20
# File 'app/sidekiq/kms_key_rotation/rotate_keys_job.rb', line 9

def perform(gids)
  Rails.logger.info { "Re-encrypting records: #{gids.join ', '}" }
  records = GlobalID::Locator.locate_many gids

  skip_hq_callback do
    records.each do |r|
      r.rotate_kms_key!
    rescue => e
      Rails.logger.error("Error rotating record (id: #{r.to_global_id}): #{e.message}")
    end
  end
end

#skip_hq_callbackObject (private)



24
25
26
27
28
# File 'app/sidekiq/kms_key_rotation/rotate_keys_job.rb', line 24

def skip_hq_callback
  HealthQuest::QuestionnaireResponse.skip_callback :save, :before, :set_user_demographics, raise: false
  yield
  HealthQuest::QuestionnaireResponse.set_callback :save, :before, :set_user_demographics, raise: false
end