Class: Orientdb4r::BinClient

Inherits:
Client
  • Object
show all
Defined in:
lib/orientdb4r/bin/client.rb

Overview

This client implements the binary protocol.

Defined Under Namespace

Classes: Connect, DbOpen, ProtocolString

Constant Summary

Constants inherited from Client

Client::SERVER_VERSION_PATTERN

Instance Attribute Summary

Attributes inherited from Client

#connection_library, #database, #lb_strategy, #load_balancing, #nodes, #password, #proxy, #user

Instance Method Summary collapse

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:



11
12
13
14
15
16
17
18
19
20
# File 'lib/orientdb4r/bin/client.rb', line 11

def initialize(options) #:nodoc:
  super()
  options_pattern = {
    :host => 'localhost', :port => 2424
  }
  verify_and_sanitize_options(options, options_pattern)

  @host = options[:host]
  @port = options[:port]
end

Instance Method Details

#connect(options) ⇒ Object

————————————————————— CONNECTION



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/orientdb4r/bin/client.rb', line 25

def connect options #:nodoc:
  options_pattern = { :database => :mandatory, :user => :mandatory, :password => :mandatory }
  verify_and_sanitize_options(options, options_pattern)
  @database = options[:database]
  @user = options[:user]
  @password = options[:password]

  socket = TCPSocket.open(@host, @port)
  protocol = BinData::Int16be.read(socket)

  Orientdb4r::logger.info "Binary protocol number: #{protocol}"

  command = DbOpen.new
  command.version = protocol
  command.database = 'temp'
  command.user = 'admin'
  command.password = 'admin'
  command.write(socket)

  resp = BinData::Int8.read(socket).to_i
  puts "EE #{resp}"

  socket.close
end

#disconnectObject

:nodoc:



51
52
# File 'lib/orientdb4r/bin/client.rb', line 51

def disconnect #:nodoc:
end

#server(options = {}) ⇒ Object

Raises:

  • (NotImplementedError)


55
56
57
# File 'lib/orientdb4r/bin/client.rb', line 55

def server(options={})
  raise NotImplementedError, 'this should be overridden by concrete client'
end