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



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/patient_http/solid_queue/request_job.rb', line 39

def perform(data, callback_service_name, raise_error_responses, callback_args, request_id)
  actual_data = PatientHttp::ExternalStorage.storage_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

  # The stored payload must not be deleted here: this job data is re-enqueued
  # for Active Job 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,
    active_job_data: active_job_data,
    request_id: request_id
  )
end