Class: Orientdb4r::Binary::BinClient
- Defined in:
- lib/orientdb4r/bin/client.rb
Overview
This client implements the binary protocol.
Constant Summary
Constants included from Constants
Constants::MINIMAL_PROTOCOL_VERSION, Constants::REQUEST_CONNECT, Constants::REQUEST_DB_OPEN, Constants::REQUEST_SHUTDOWN, Constants::STATUS_ERROR, Constants::STATUS_OK
Constants inherited from Client
Client::SERVER_VERSION_PATTERN
Instance Attribute Summary collapse
-
#db_connection ⇒ Object
readonly
Returns the value of attribute db_connection.
-
#protocol ⇒ Object
readonly
Returns the value of attribute protocol.
-
#protocol_version ⇒ Object
readonly
Returns the value of attribute protocol_version.
-
#server_connection ⇒ Object
readonly
Returns the value of attribute server_connection.
Attributes inherited from Client
#connection_library, #database, #lb_strategy, #load_balancing, #nodes, #password, #proxy, #user
Instance Method Summary collapse
-
#connect(options) ⇒ Object
————————————————————— CONNECTION.
-
#disconnect ⇒ Object
:nodoc:.
-
#initialize(options) ⇒ BinClient
constructor
:nodoc:.
- #server(options = {}) ⇒ Object
Methods included from OIO
Methods inherited from Client
#class_exists?, #command, #connected?, #create_class, #create_database, #create_document, #create_property, #database_exists?, #delete_database, #delete_document, #drop_class, #export, #get_class, #get_database, #get_document, #import, #list_databases, #query, #update_document
Methods included from Utils
#blank?, #compare_versions, #random_string, #verify_and_sanitize_options, #verify_options
Constructor Details
#initialize(options) ⇒ BinClient
:nodoc:
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/orientdb4r/bin/client.rb', line 24 def initialize() #:nodoc: super() = { :host => 'localhost', :port => 2424 } (, ) @host = [:host] @port = [:port] end |
Instance Attribute Details
#db_connection ⇒ Object (readonly)
Returns the value of attribute db_connection.
19 20 21 |
# File 'lib/orientdb4r/bin/client.rb', line 19 def db_connection @db_connection end |
#protocol ⇒ Object (readonly)
Returns the value of attribute protocol.
20 21 22 |
# File 'lib/orientdb4r/bin/client.rb', line 20 def protocol @protocol end |
#protocol_version ⇒ Object (readonly)
Returns the value of attribute protocol_version.
21 22 23 |
# File 'lib/orientdb4r/bin/client.rb', line 21 def protocol_version @protocol_version end |
#server_connection ⇒ Object (readonly)
Returns the value of attribute server_connection.
18 19 20 |
# File 'lib/orientdb4r/bin/client.rb', line 18 def server_connection @server_connection end |
Instance Method Details
#connect(options) ⇒ Object
————————————————————— CONNECTION
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/orientdb4r/bin/client.rb', line 38 def connect #:nodoc: = { :database => :mandatory, :user => :mandatory, :password => :mandatory, :session => :optional, :db_type => 'document' } (, ) @socket = TCPSocket.open(@host, @port) @protocol_version = BinData::Int16be.read(@socket).to_i Orientdb4r::logger.info "Binary protocol version: #{@protocol_version}" # check minimal protocol version which is supported @protocol = ProtocolFactory.get_protocol(protocol_version) command = protocol::DbOpenRequest.new(:protocol_version => protocol_version, :db_name => [:database], :user => [:user], :password => [:password]) resp = req_resp(@socket, command, protocol::DbOpenResponse.new) db_connection = Orientdb4r::Binary::Connection.new(resp.session, ) Orientdb4r::logger.info "Database connected, session=#{db_connection.session_id}" end |
#disconnect ⇒ Object
:nodoc:
58 59 60 61 62 63 64 65 |
# File 'lib/orientdb4r/bin/client.rb', line 58 def disconnect #:nodoc: @socket.close @protocol = nil @protocol_version = 0 @db_connection.close unless @db_connection.nil? @server_connection.close unless @server_connection.nil? @db_connection = nil end |
#server(options = {}) ⇒ Object
68 69 70 |
# File 'lib/orientdb4r/bin/client.rb', line 68 def server(={}) raise NotImplementedError, 'this should be overridden by concrete client' end |