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.
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/patient_http/sidekiq/request_worker.rb', line 44 def perform(data, callback_service_name, raise_error_responses, callback_args, request_id) # Fetch from external storage if needed actual_data = PatientHttp::ExternalStorage.storage_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 # The stored payload must not be deleted here: this job hash is re-pushed # for Sidekiq retries (e.g. MaxCapacityError), processor shutdown retries, # and crash recovery, all of which need to fetch the payload again. # TaskHandler deletes it when the request completes. 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 ) end |