Class: Orientdb4r::RestClientNode
- Defined in:
- lib/orientdb4r/rest/restclient_node.rb
Overview
This class represents a single sever/node in the Distributed Multi-Master Architecture accessible via REST API and ‘rest-client’ library on the client side.
Constant Summary
Constants inherited from RestNode
Orientdb4r::RestNode::SESSION_COOKIE_NAME
Instance Attribute Summary
Attributes inherited from RestNode
Attributes inherited from Node
Instance Method Summary collapse
-
#request(options) ⇒ Object
:nodoc:.
Methods inherited from RestNode
Methods inherited from Node
#cleanup, #initialize, #to_s, #url
Methods included from Utils
#blank?, #compare_versions, #random_string, #verify_and_sanitize_options, #verify_options
Constructor Details
This class inherits a constructor from Orientdb4r::RestNode
Instance Method Details
#request(options) ⇒ Object
:nodoc:
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/orientdb4r/rest/restclient_node.rb', line 10 def request() #:nodoc: (, {:user => :mandatory, :password => :mandatory, \ :uri => :mandatory, :method => :mandatory, :content_type => :optional, :data => :optional}) opts = .clone # if not cloned we change original hash map that cannot be used more with load balancing # URL opts[:url] = "#{url}/#{opts[:uri]}" opts.delete :uri # data data = opts.delete :data data = '' if data.nil? and :post == opts[:method] # POST has to have data opts[:payload] = data unless data.nil? # cookies opts[:cookies] = { SESSION_COOKIE_NAME => session_id} unless session_id.nil? # headers opts[:headers] = { 'User-Agent' => user_agent } unless user_agent.nil? begin response = ::RestClient::Request.new(opts).execute # store session ID if received to reuse in next request sessid = response.[SESSION_COOKIE_NAME] if session_id != sessid @session_id = sessid Orientdb4r::logger.debug "new session id: #{session_id}" end rescue Errno::ECONNREFUSED raise NodeError rescue ::RestClient::ServerBrokeConnection raise NodeError rescue ::RestClient::Exception => e response = transform_error2_response(e) end response end |