Class: Alephant::Publisher::Request::Connection
- Inherits:
-
Object
- Object
- Alephant::Publisher::Request::Connection
- Includes:
- LogHelper, Logger
- Defined in:
- lib/alephant/publisher/request/connection.rb
Instance Attribute Summary collapse
-
#driver ⇒ Object
readonly
Returns the value of attribute driver.
Instance Method Summary collapse
- #get(uri) ⇒ Object
-
#initialize(driver) ⇒ Connection
constructor
A new instance of Connection.
Methods included from LogHelper
Constructor Details
#initialize(driver) ⇒ Connection
Returns a new instance of Connection.
12 13 14 |
# File 'lib/alephant/publisher/request/connection.rb', line 12 def initialize(driver) @driver = driver end |
Instance Attribute Details
#driver ⇒ Object (readonly)
Returns the value of attribute driver.
10 11 12 |
# File 'lib/alephant/publisher/request/connection.rb', line 10 def driver @driver end |
Instance Method Details
#get(uri) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/alephant/publisher/request/connection.rb', line 16 def get(uri) JSON::parse(request(uri).body, :symbolize_names => true) rescue Faraday::ConnectionFailed => e log_error_with_metric(e, 'Connection#request', uri, "PublisherRequestConnectionConnectionFailed") raise ConnectionFailed rescue InvalidApiStatus => e log_error_with_metric(e, 'Connection#request', uri, "PublisherRequestConnectionInvalidStatus#{e.status}") raise e rescue JSON::ParserError => e log_error_with_metric(e, 'Connection#get', uri, "PublisherRequestConnectionInvalidApiResponse") raise InvalidApiResponse, "JSON parsing error: #{response.body}" rescue StandardError => e log_error_with_metric(e, 'Connection#get', uri, "PublisherRequestConnectionApiError") raise ApiError, e. end |