class Angus::Remote::ProxyClient
A client for service invocation when proxing requests.
Public Class Methods
new(url, timeout = 60)
click to toggle source
# File lib/angus/remote/proxy_client.rb, line 13 def initialize(url, timeout = 60) url = url[0..-2] if url[-1] == '/' @connection = PersistentHTTP.new( :pool_size => 4, :pool_timeout => 10, :warn_timeout => 0.25, :force_retry => false, :url => url, :read_timeout => timeout, :open_timeout => timeout ) @api_base_path = @connection.default_path end
Public Instance Methods
make_request(method, path, query, headers = {}, body = nil)
click to toggle source
Makes a request to the service
# File lib/angus/remote/proxy_client.rb, line 32 def make_request(method, path, query, headers = {}, body = nil) full_path = @api_base_path + path request = ProxyClientUtils.build_request(method, full_path, query, headers, body) begin response = @connection.request(request) from_headers = ProxyClientUtils.normalize_headers( ProxyClientUtils.filter_response_headers(response.to_hash) ) [response.code.to_i, from_headers, [response.body]] rescue Errno::ECONNREFUSED => e raise RemoteConnectionError.new("#{self.class.base_uri} - #{e.class}: #{e.message}") end end
to_s()
click to toggle source
# File lib/angus/remote/proxy_client.rb, line 50 def to_s "#<#{self.class}:#{object_id}>" end