Class: Neo4j::Core::CypherSession::Adaptors::Bolt

Inherits:
Base
  • Object
show all
Includes:
HasUri, Schema
Defined in:
lib/neo4j/core/cypher_session/adaptors/bolt.rb

Defined Under Namespace

Classes: Job, Message

Constant Summary collapse

SUPPORTED_VERSIONS =
[1, 0, 0, 0].freeze
VERSION =
'0.0.1'.freeze

Constants inherited from Base

Neo4j::Core::CypherSession::Adaptors::Base::EMPTY, Neo4j::Core::CypherSession::Adaptors::Base::NEWLINE_W_SPACES, Neo4j::Core::CypherSession::Adaptors::Base::USER_AGENT_STRING

Instance Attribute Summary

Attributes inherited from Base

#options, #wrap_level

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Schema

#constraints, #indexes, #version

Methods included from HasUri

#url, #url=, #url_without_password

Methods inherited from Base

#close, #default_subscribe, #logger, #queries, #query, #setup_queries!, #supports_metadata?, #transaction

Methods included from Instrumentable

included

Constructor Details

#initialize(url, options = {}) ⇒ Bolt

Returns a new instance of Bolt.



25
26
27
28
29
30
31
32
33
34
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 25

def initialize(url, options = {})
  self.url = url
  @options = options
  @net_tcp_client_options = {read_timeout: options.fetch(:read_timeout, -1),
                             write_timeout: options.fetch(:write_timeout, -1),
                             connect_timeout: options.fetch(:connect_timeout, 10),
                             ssl: options.fetch(:ssl, {})}

  open_socket
end

Class Method Details

.transaction_classObject



62
63
64
65
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 62

def self.transaction_class
  require 'neo4j/core/cypher_session/transactions/bolt'
  Neo4j::Core::CypherSession::Transactions::Bolt
end

Instance Method Details

#connectObject



36
37
38
39
40
41
42
43
44
45
46
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 36

def connect
  handshake

  init

  message = flush_messages[0]
  return if message.type == :success

  data = message.args[0]
  fail "Init did not complete successfully\n\n#{data['code']}\n#{data['message']}"
end

#connected?Boolean

Returns:

  • (Boolean)


58
59
60
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 58

def connected?
  !!@tcp_client && !@tcp_client.closed?
end

#query_set(transaction, queries, options = {}) ⇒ Object



48
49
50
51
52
53
54
55
56
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 48

def query_set(transaction, queries, options = {})
  setup_queries!(queries, transaction, skip_instrumentation: options[:skip_instrumentation])

  self.class.instrument_request(self) do
    send_query_jobs(queries)

    build_response(queries, options[:wrap_level] || @options[:wrap_level])
  end
end

#ssl?Boolean

Returns:

  • (Boolean)


75
76
77
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 75

def ssl?
  @tcp_client.socket.is_a?(OpenSSL::SSL::SSLSocket)
end