diff --git a/app/sidekiq/central_mail/submit_form4142_job.rb b/app/sidekiq/central_mail/submit_form4142_job.rb index b4cdf13452a..c56fa1bb21e 100644 --- a/app/sidekiq/central_mail/submit_form4142_job.rb +++ b/app/sidekiq/central_mail/submit_form4142_job.rb @@ -21,17 +21,10 @@ class SubmitForm4142Job < EVSS::DisabilityCompensationForm::Job } ) - STATSD_KEY_PREFIX = 'worker.evss.submit_form4142' + CENTRAL_MAIL_STATSD_KEY_PREFIX = 'worker.evss.submit_form4142' + LIGHTHOUSE_STATSD_KEY_PREFIX = 'worker.lighthouse.submit_form4142' - # Sidekiq has built in exponential back-off functionality for retries - # A max retry attempt of 10 will result in a run time of ~8 hours - # This job is invoked from 526 background job, ICMHS is reliable - # and hence this value is set at a lower value - RETRY = 10 - - sidekiq_options retry: RETRY - - class CentralMailResponseError < Common::Exceptions::BackendServiceException; end + class BenefitsIntake4142Error < StandardError; end sidekiq_retries_exhausted do |msg, _ex| job_id = msg['jid'] @@ -51,6 +44,7 @@ class CentralMailResponseError < Common::Exceptions::BackendServiceException; en form526_submission_id: } } + # [wipn8923] update use of statsD keys form_job_status.update( status: Form526JobStatus::STATUS[:exhausted], bgjob_errors: bgjob_errors.merge(new_error) @@ -82,6 +76,7 @@ class CentralMailResponseError < Common::Exceptions::BackendServiceException; en # # @param submission_id [Integer] the {Form526Submission} id # + # [wipn8923] job to update? def perform(submission_id) @submission_id = submission_id @@ -90,7 +85,7 @@ def perform(submission_id) with_tracking('Form4142 Submission', submission.saved_claim_id, submission.id) do @pdf_path = processor.pdf_path - response = upload_to_central_mail + response = upload_to_api handle_service_exception(response) if response.present? && response.status.between?(201, 600) end rescue => e @@ -109,10 +104,31 @@ def processor @processor ||= EVSS::DisabilityCompensationForm::Form4142Processor.new(submission, jid) end + def upload_to_api + if Flipper.enabled?(:disability_compensation_form_4142) + upload_to_lighthouse + else + upload_to_central_mail + end + end + def upload_to_central_mail CentralMail::Service.new.upload(processor.request_body) end + def upload_to_lighthouse + @lighthouse_service = BenefitsIntakeService::Service.new(with_upload_location: true) + payload = { + upload_url: @lighthouse_service.location, + file: { file: @pdf_path, file_name: @pdf_path.split('/').last }, + metadata: generate_metadata.to_json, + attachments: [] # wipn8923 is this better than nil? + } + create_form_submission_attempt + + @lighthouse_service.upload_doc(**paylod) + end + # Cannot move job straight to dead queue dynamically within an executing job # raising error for all the exceptions as sidekiq will then move into dead queue # after all retries are exhausted diff --git a/app/sidekiq/lighthouse/submit_benefits_intake_claim.rb b/app/sidekiq/lighthouse/submit_benefits_intake_claim.rb index 34553145270..66d9df760b8 100644 --- a/app/sidekiq/lighthouse/submit_benefits_intake_claim.rb +++ b/app/sidekiq/lighthouse/submit_benefits_intake_claim.rb @@ -8,6 +8,7 @@ require 'pdf_info' module Lighthouse + # [wipn8923] API template class SubmitBenefitsIntakeClaim include Sidekiq::Job include SentryLogging diff --git a/lib/decision_review_v1/utilities/form_4142_processor.rb b/lib/decision_review_v1/utilities/form_4142_processor.rb index e11849792cd..46f5b1fdcf1 100644 --- a/lib/decision_review_v1/utilities/form_4142_processor.rb +++ b/lib/decision_review_v1/utilities/form_4142_processor.rb @@ -7,6 +7,7 @@ module DecisionReviewV1 module Processor + # [wipn8923] why is this being used in the backup path? class Form4142Processor # @return [Pathname] the generated PDF path attr_reader :pdf_path diff --git a/lib/evss/disability_compensation_form/form4142_processor.rb b/lib/evss/disability_compensation_form/form4142_processor.rb index 446f5d55349..a36b3f4b8ce 100644 --- a/lib/evss/disability_compensation_form/form4142_processor.rb +++ b/lib/evss/disability_compensation_form/form4142_processor.rb @@ -16,6 +16,7 @@ module DisabilityCompensationForm # A {Form4142Processor} handles the work of generating a stamped PDF # and a request body for a 4142 CentralMail submission # + # [wipn8923] seems to be the processor I want class Form4142Processor # @return [Pathname] the generated PDF path attr_reader :pdf_path