Class: Dor::Workflow::Client::Requestor
- Inherits:
-
Object
- Object
- Dor::Workflow::Client::Requestor
- Defined in:
- lib/dor/workflow/client/requestor.rb
Overview
Makes requests to the workflow service and retries them if necessary.
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
Instance Method Summary collapse
-
#initialize(connection:) ⇒ Requestor
constructor
A new instance of Requestor.
-
#request(uri_string, meth = 'get', payload = '', opts = {}) ⇒ Object
calls workflow_resource[uri_string]."#meth" with variable number of optional arguments The point of this is to wrap ALL remote calls with consistent error handling and logging.
Constructor Details
#initialize(connection:) ⇒ Requestor
Returns a new instance of Requestor.
8 9 10 |
# File 'lib/dor/workflow/client/requestor.rb', line 8 def initialize(connection:) @connection = connection end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
12 13 14 |
# File 'lib/dor/workflow/client/requestor.rb', line 12 def connection @connection end |
Instance Method Details
#request(uri_string, meth = 'get', payload = '', opts = {}) ⇒ Object
calls workflow_resource[uri_string]."#meth" with variable number of optional arguments The point of this is to wrap ALL remote calls with consistent error handling and logging
21 22 23 24 25 26 27 28 |
# File 'lib/dor/workflow/client/requestor.rb', line 21 def request(uri_string, meth = 'get', payload = '', opts = {}) response = send_workflow_resource_request(uri_string, meth, payload, opts) response.body rescue Faraday::Error => e msg = "Failed to retrieve resource: #{meth} #{base_url}/#{uri_string}" msg += " (HTTP status #{e.response[:status]})" if e.respond_to?(:response) && e.response raise Dor::WorkflowException, msg end |