Class: PatientHttp::SolidQueue::RequestJob Private

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/patient_http/solid_queue/request_job.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.

Active Job that executes HTTP requests asynchronously.

Enqueued when calling PatientHttp::SolidQueue.get, .post, etc. On completion, the specified callback service’s on_complete or on_error is invoked via CallbackJob.

Instance Method Summary collapse

Instance Method Details

#perform(data, callback_service_name, raise_error_responses, callback_args, request_id) ⇒ Object

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.

Parameters:

  • data (Hash)

    Request data (possibly a storage reference)

  • callback_service_name (String)

    Fully qualified callback service class name

  • raise_error_responses (Boolean, nil)

    Whether to treat non-2xx responses as errors

  • callback_args (Hash, nil)

    Arguments to pass to the callback

  • request_id (String, nil)

    Unique request ID for tracking



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/patient_http/solid_queue/request_job.rb', line 23

def perform(data, callback_service_name, raise_error_responses, callback_args, request_id)
  ref_data = PatientHttp::ExternalStorage.storage_ref?(data) ? data : nil
  actual_data = ref_data ? PatientHttp::SolidQueue.external_storage.fetch(data) : data
  actual_data = PatientHttp::SolidQueue.decrypt(actual_data)

  request = PatientHttp::Request.load(actual_data)
  active_job_data = PatientHttp::SolidQueue::Context.current_job

  begin
    RequestExecutor.execute(
      request,
      callback: callback_service_name,
      raise_error_responses: raise_error_responses,
      callback_args: callback_args,
      active_job_data: active_job_data,
      request_id: request_id
    )
  ensure
    PatientHttp::SolidQueue.external_storage.delete(ref_data) if ref_data
  end
end