Class: Neo4j::Core::CypherSession::Adaptors::Bolt
- Inherits:
-
Base
- Object
- Base
- Neo4j::Core::CypherSession::Adaptors::Bolt
show all
- Includes:
- HasUri
- 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
#wrap_level
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from HasUri
#url, #url=
Methods inherited from Base
instrument_queries, #logger, #queries, #query, #setup_queries!, #transaction
included
Constructor Details
#initialize(url, options = {}) ⇒ Bolt
Returns a new instance of Bolt.
24
25
26
27
28
29
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 24
def initialize(url, options = {})
self.url = url
@options = options
open_socket
end
|
Class Method Details
.transaction_class ⇒ Object
88
89
90
91
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 88
def self.transaction_class
require 'neo4j/core/cypher_session/transactions/bolt'
Neo4j::Core::CypherSession::Transactions::Bolt
end
|
Instance Method Details
#connect ⇒ Object
31
32
33
34
35
36
37
38
39
40
41
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 31
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
66
67
68
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 66
def connected?
!!@socket
end
|
#constraints(session) ⇒ Object
79
80
81
82
83
84
85
86
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 79
def constraints(session)
result = query(session, 'CALL db.indexes()', {}, skip_instrumentation: true)
result.select { |row| row.type == 'node_unique_property' }.map do |row|
label, property = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)[1, 2]
{type: :uniqueness, label: label.to_sym, properties: [property.to_sym]}
end
end
|
#indexes(session) ⇒ Object
70
71
72
73
74
75
76
77
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 70
def indexes(session)
result = query(session, 'CALL db.indexes()', {}, skip_instrumentation: true)
result.map do |row|
label, property = row.description.match(/INDEX ON :([^\(]+)\(([^\)]+)\)/)[1, 2]
{type: row.type.to_sym, label: label.to_sym, properties: [property.to_sym], state: row.state.to_sym}
end
end
|
#query_set(transaction, queries, options = {}) ⇒ Object
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 43
def query_set(transaction, queries, options = {})
setup_queries!(queries, transaction, skip_instrumentation: options[:skip_instrumentation])
if @socket.ready?
debug_remaining_buffer
fail "Making query, but expected there to be no buffer remaining!\n"\
"Queries: #{queries.map(&:cypher)}"
end
self.class.instrument_request do
send_query_jobs(queries)
build_response(queries, options[:wrap_level] || @options[:wrap_level])
end
end
|
#version(session) ⇒ Object
59
60
61
62
63
64
|
# File 'lib/neo4j/core/cypher_session/adaptors/bolt.rb', line 59
def version(session)
result = query(session, 'CALL dbms.components()', {}, skip_instrumentation: true)
result.first.versions[0]
end
|