Class: PatientHttp::Sidekiq::RequestWorker Private
- Inherits:
-
Object
- Object
- PatientHttp::Sidekiq::RequestWorker
- Includes:
- Sidekiq::Job
- Defined in:
- lib/patient_http/sidekiq/request_worker.rb
Overview
This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.
Sidekiq worker for executing HTTP requests asynchronously.
This worker is enqueued when calling PatientHttp::Sidekiq.get, PatientHttp::Sidekiq.post, etc. It allows HTTP requests to be made from anywhere in your code (not just Sidekiq jobs) while still processing them through the async HTTP processor.
When the request completes, the specified callback service’s on_complete or on_error method is invoked via CallbackWorker.
Instance Method Summary collapse
-
#perform(data, callback_service_name, raise_error_responses, callback_args, request_id) ⇒ void
private
Perform the HTTP request.
Instance Method Details
#perform(data, callback_service_name, raise_error_responses, callback_args, request_id) ⇒ void
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
This method returns an undefined value.
Perform the HTTP request.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/patient_http/sidekiq/request_worker.rb', line 33 def perform(data, callback_service_name, raise_error_responses, callback_args, request_id) # Fetch from external storage if needed ref_data = PatientHttp::ExternalStorage.storage_ref?(data) ? data : nil actual_data = ref_data ? Sidekiq.external_storage.fetch(data) : data actual_data = Sidekiq.decrypt(actual_data) request = PatientHttp::Request.load(actual_data) sidekiq_job = Sidekiq::Context.current_job begin RequestExecutor.execute( request, callback: callback_service_name, raise_error_responses: raise_error_responses, callback_args: callback_args, sidekiq_job: sidekiq_job, request_id: request_id ) ensure Sidekiq.external_storage.delete(ref_data) if ref_data end end |