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, processor_name = nil) ⇒ 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

  • processor_name (String, nil) (defaults to: nil)

    Name of the processor profile to run the request on; nil (jobs enqueued by older versions) runs on the default processor



48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
# File 'lib/patient_http/solid_queue/request_job.rb', line 48

def perform(data, callback_service_name, raise_error_responses, callback_args, request_id, processor_name = nil)
  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,
    processor_name: processor_name || "default"
  )
end